Commit 35ef784e authored by Jonathan.Wage's avatar Jonathan.Wage

Initial entry of Doctrine_Resource and other fixes.

parent f4eeb641
......@@ -37,36 +37,7 @@
* @author Nicolas Bérard-Nault <nicobn@gmail.com>
*/
class Doctrine_Export_Schema
{
/**
* build
*
* Build the schema string to be dumped to file
*
* @param string $array
* @return void
*/
public function build($array)
{
throw new Doctrine_Export_Exception('This functionality is implemented by the driver');
}
/**
* dump
*
* Dump the array to the schema file
*
* @param string $array
* @param string $schema
* @return void
*/
public function dump($array, $schema)
{
$data = $this->build($array);
file_put_contents($schema, $data);
}
{
/**
* buildSchema
*
......@@ -171,11 +142,8 @@ class Doctrine_Export_Schema
*/
public function exportSchema($schema, $format, $directory, $models = array())
{
$className = 'Doctrine_Export_Schema_'.ucwords($format);
$export = new $className();
$array = $export->buildSchema($directory, $models);
$array = $this->buildSchema($directory, $models);
return $export->dump($array, $schema);
Doctrine_Parser::dump($array, $format, $schema);
}
}
\ No newline at end of file
<?php
/*
* $Id: Xml.php 1838 2007-06-26 00:58:21Z nicobn $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* class Doctrine_Export_Schema_Xml
*
* @package Doctrine
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version $Revision: 1838 $
* @author Nicolas Bérard-Nault <nicobn@gmail.com>
*/
class Doctrine_Export_Schema_Xml extends Doctrine_Export_Schema
{
/**
* build
*
* Build the schema xml string to be dumped to file
*
* @param string $array
* @return void
*/
public function build($array)
{
return Doctrine_Parser::dump($array, 'yml');
}
}
\ No newline at end of file
<?php
/*
* $Id: Yml.php 1838 2007-06-26 00:58:21Z nicobn $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* class Doctrine_Export_Schema_Yml
*
* @package Doctrine
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version $Revision: 1838 $
* @author Nicolas Bérard-Nault <nicobn@gmail.com>
*/
class Doctrine_Export_Schema_Yml extends Doctrine_Export_Schema
{
/**
* build
*
* Build the schema yml string to be dumped to file
*
* @param string $array
* @return void
*/
public function build($array)
{
return Doctrine_Parser::dump($array, 'yml');
}
}
\ No newline at end of file
......@@ -41,34 +41,7 @@ class Doctrine_Import_Schema
{
public $relations = array();
/**
* Parse the schema and return it in an array
*
* @param string $schema
* @access public
*/
public function parseSchema($schema)
{
throw new Doctrine_Import_Exception('This functionality is implemented by the driver');
}
/**
* parse
*
* Function to do the actual parsing of the file
*
* @param string $schema
* @return void
* @author Jonathan H. Wage
*/
public function parse($schema)
{
$class = get_class($this);
$type = strtolower(str_replace('Doctrine_Import_Schema_', '', $class));
return Doctrine_Parser::load($schema, $type);
}
/**
* importSchema
*
......@@ -82,19 +55,15 @@ class Doctrine_Import_Schema
*/
public function importSchema($schema, $format, $directory, $models = array())
{
$className = 'Doctrine_Import_Schema_'.ucwords($format);
$import = new $className();
$builder = new Doctrine_Import_Builder();
$builder->setTargetPath($directory);
$array = array();
foreach ((array) $schema AS $s) {
$array = array_merge($array, $import->parseSchema($s));
$array = array_merge($array, $this->parseSchema($s, $format));
}
$import->buildRelationships($array);
$this->buildRelationships($array);
foreach ($array as $name => $properties) {
if (!empty($models) && !in_array($properties['className'], $models)) {
......@@ -107,11 +76,59 @@ class Doctrine_Import_Schema
$columns = $properties['columns'];
$relations = isset($import->relations[$options['className']]) ? $import->relations[$options['className']]:array();
$relations = isset($this->relations[$options['className']]) ? $this->relations[$options['className']]:array();
$builder->buildRecord($options, $columns, $relations);
}
}
}
/**
* parseSchema
*
* A method to parse a Yml Schema and translate it into a property array.
* The function returns that property array.
*
* @param string $schema Path to the file containing the XML schema
* @return array
*/
public function parseSchema($schema, $type)
{
$array = Doctrine_Parser::load($schema, $type);
$build = array();
foreach ($array as $className => $table) {
$columns = array();
$className = isset($table['className']) ? (string) $table['className']:(string) $className;
$tableName = isset($table['tableName']) ? (string) $table['tableName']:(string) $className;
foreach ($table['columns'] as $columnName => $field) {
$colDesc = array();
$colDesc['name'] = isset($field['name']) ? (string) $field['name']:$columnName;
$colDesc['type'] = isset($field['type']) ? (string) $field['type']:null;
$colDesc['ptype'] = isset($field['ptype']) ? (string) $field['ptype']:(string) $colDesc['type'];
$colDesc['length'] = isset($field['length']) ? (int) $field['length']:null;
$colDesc['fixed'] = isset($field['fixed']) ? (int) $field['fixed']:null;
$colDesc['unsigned'] = isset($field['unsigned']) ? (bool) $field['unsigned']:null;
$colDesc['primary'] = isset($field['primary']) ? (bool) (isset($field['primary']) && $field['primary']):null;
$colDesc['default'] = isset($field['default']) ? (string) $field['default']:null;
$colDesc['notnull'] = isset($field['notnull']) ? (bool) (isset($field['notnull']) && $field['notnull']):null;
$colDesc['autoinc'] = isset($field['autoinc']) ? (bool) (isset($field['autoinc']) && $field['autoinc']):null;
$columns[(string) $colDesc['name']] = $colDesc;
}
$build[$className]['tableName'] = $tableName;
$build[$className]['className'] = $className;
$build[$className]['columns'] = $columns;
$build[$className]['relations'] = isset($table['relations']) ? $table['relations']:array();
}
return $build;
}
public function buildRelationships($array)
{
......
<?php
/*
* $Id: Xml.php 1838 2007-06-26 00:58:21Z nicobn $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* class Doctrine_Import_Xml
*
* Different methods to import a XML schema. The logic behind using two different
* methods is simple. Some people will like the idea of producing Doctrine_Record
* objects directly, which is totally fine. But in fast and growing application,
* table definitions tend to be a little bit more volatile. importArr() can be used
* to output a table definition in a PHP file. This file can then be stored
* independantly from the object itself.
*
* @package Doctrine
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version $Revision: 1838 $
* @author Nicolas Bérard-Nault <nicobn@gmail.com>
* @author Jonathan H. Wage <jonwage@gmail.com>
*/
class Doctrine_Import_Schema_Xml extends Doctrine_Import_Schema
{
/**
* parseSchema
*
* A method to parse a XML Schema and translate it into a property array.
* The function returns that property array.
*
* @param string $schema Path to the file containing the XML schema
* @return array
*/
public function parseSchema($schema)
{
$xmlObj = $this->parse($schema);
foreach ($xmlObj->tables as $table) {
$columns = array();
// Go through all columns...
foreach ($table->columns as $column) {
$colDesc = array(
'name' => (string) $column->name,
'type' => (string) $column->type,
'ptype' => (string) $column->type,
'length' => (int) $column->length,
'fixed' => (int) $column->fixed,
'unsigned' => (bool) $column->unsigned,
'primary' => (bool) (isset($column->primary) && $column->primary),
'default' => (string) $column->default,
'notnull' => (bool) (isset($column->notnull) && $column->notnull),
'autoinc' => (bool) (isset($column->autoincrement) && $column->autoincrement),
);
$columns[(string) $column->name] = $colDesc;
}
$class = $table->class ? (string) $table->class:(string) $table->name;
$tables[(string) $table->name]['name'] = (string) $table->name;
$tables[(string) $table->name]['class'] = (string) $class;
$tables[(string) $table->name]['columns'] = $columns;
}
return $tables;
}
}
\ No newline at end of file
<?php
/*
* $Id: Yml.php 1838 2007-06-26 00:58:21Z nicobn $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* class Doctrine_Import_Schema_Yml
*
* Different methods to import a YML schema. The logic behind using two different
* methods is simple. Some people will like the idea of producing Doctrine_Record
* objects directly, which is totally fine. But in fast and growing application,
* table definitions tend to be a little bit more volatile. importArr() can be used
* to output a table definition in a PHP file. This file can then be stored
* independantly from the object itself.
*
* @package Doctrine
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version $Revision: 1838 $
* @author Nicolas Bérard-Nault <nicobn@gmail.com>
* @author Jonathan H. Wage <jonwage@gmail.com>
*/
class Doctrine_Import_Schema_Yml extends Doctrine_Import_Schema
{
/**
* parseSchema
*
* A method to parse a Yml Schema and translate it into a property array.
* The function returns that property array.
*
* @param string $schema Path to the file containing the XML schema
* @return array
*/
public function parseSchema($schema)
{
$array = $this->parse($schema);
foreach ($array as $className => $table) {
$columns = array();
$className = isset($table['className']) ? (string) $table['className']:(string) $className;
$tableName = isset($table['tableName']) ? (string) $table['tableName']:(string) $className;
foreach ($table['columns'] as $columnName => $field) {
$colDesc = array();
$colDesc['name'] = isset($field['name']) ? (string) $field['name']:$columnName;
$colDesc['type'] = isset($field['type']) ? (string) $field['type']:null;
$colDesc['ptype'] = isset($field['ptype']) ? (string) $field['ptype']:(string) $colDesc['type'];
$colDesc['length'] = isset($field['length']) ? (int) $field['length']:null;
$colDesc['fixed'] = isset($field['fixed']) ? (int) $field['fixed']:null;
$colDesc['unsigned'] = isset($field['unsigned']) ? (bool) $field['unsigned']:null;
$colDesc['primary'] = isset($field['primary']) ? (bool) (isset($field['primary']) && $field['primary']):null;
$colDesc['default'] = isset($field['default']) ? (string) $field['default']:null;
$colDesc['notnull'] = isset($field['notnull']) ? (bool) (isset($field['notnull']) && $field['notnull']):null;
$colDesc['autoinc'] = isset($field['autoinc']) ? (bool) (isset($field['autoinc']) && $field['autoinc']):null;
$columns[(string) $colDesc['name']] = $colDesc;
}
$tables[$className]['tableName'] = $tableName;
$tables[$className]['className'] = $className;
$tables[$className]['columns'] = $columns;
$tables[$className]['relations'] = isset($table['relations']) ? $table['relations']:array();
}
return $tables;
}
}
\ No newline at end of file
......@@ -67,18 +67,48 @@ class Doctrine_Parser_Xml extends Doctrine_Parser
public function loadData($path)
{
if ( !file_exists($path) OR !is_writeable($path) ) {
throw new Doctrine_Parser_Exception('Xml file '. $path .' could not be read');
if (file_exists($path) && is_readable($path)) {
$xmlString = file_get_contents($path);
} else {
$xmlString = $path;
}
if ( ! ($xmlString = file_get_contents($path))) {
throw new Doctrine_Parser_Exception('Xml file '. $path . ' is empty');
}
$simpleXml = simplexml_load_string($xmlString);
if (!file_exists($path) OR !is_readable($path) OR !($xmlString = file_get_contents($path))) {
$xmlString = $path;
return $this->prepareData($simpleXml);
}
public function prepareData($simpleXml)
{
if ($simpleXml instanceof SimpleXMLElement) {
$children = $simpleXml->children();
$return = null;
}
foreach ($children as $element => $value) {
if ($value instanceof SimpleXMLElement) {
$values = (array)$value->children();
if (count($values) > 0) {
$return[$element] = $this->prepareData($value);
} else {
if (!isset($return[$element])) {
$return[$element] = (string)$value;
} else {
if (!is_array($return[$element])) {
$return[$element] = array($return[$element], (string)$value);
} else {
$return[$element][] = (string)$value;
}
}
}
}
}
if (is_array($return)) {
return $return;
} else {
return $false;
}
return simplexml_load_string($xmlString);
}
}
\ No newline at end of file
<?php
class Doctrine_Resource
{
}
\ No newline at end of file
This diff is collapsed.
<?php
class Doctrine_Resource_Server extends Doctrine_Resource
{
public function execute($request)
{
if (isset($request['dql'])) {
$query = new Doctrine_Query();
$result = $query->query($request['dql']);
} else {
$result = $this->buildDql($request['parts']);
}
$data = array();
foreach ($result as $recordKey => $record) {
$array = $record->toArray();
$recordKey = get_class($record). '_' .($recordKey + 1);
foreach ($array as $valueKey => $value) {
$data[get_class($record)][$recordKey][$valueKey] = $value;
}
}
$format = isset($request['format']) ? $request['format']:'xml';
return Doctrine_Parser::dump($data, $format);
}
public function buildDql($parts)
{
}
public function run()
{
$request = $_REQUEST;
echo $this->execute($request);
}
}
\ No newline at end of file
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Export_Schema_Xml_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_Export_Schema_Xml_TestCase extends Doctrine_UnitTestCase
{
}
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Export_Schema_Yml_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_Export_Schema_Yml_TestCase extends Doctrine_UnitTestCase
{
}
......@@ -20,7 +20,7 @@
*/
/**
* Doctrine_Import_Schema_Xml_TestCase
* Doctrine_Export_Schema_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
......@@ -30,23 +30,38 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Import_Schema_Xml_TestCase extends Doctrine_UnitTestCase
class Doctrine_Export_Schema_TestCase extends Doctrine_UnitTestCase
{
public function testXmlImport()
public $tables = array('Entity',
'EntityReference',
'EntityAddress',
'Email',
'Phonenumber',
'Groupuser',
'Group',
'User',
'Album',
'Song',
'Element',
'Error',
'Description',
'Address',
'Account',
'Task',
'Resource',
'Assignment',
'ResourceType',
'ResourceReference');
public function testYmlExport()
{
$import = new Doctrine_Import_Schema_Xml();
$import->importSchema('schema.xml', 'classes');
if ( ! file_exists('classes/User.class.php')) {
$this->fail();
} else {
unlink('classes/User.class.php');
}
if ( ! file_exists('classes/Group.class.php')) {
$this->fail();
} else {
unlink('classes/Group.class.php');
}
$export = new Doctrine_Export_Schema();
$export->exportSchema('schema.yml', 'yml', dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'models', $this->tables);
}
public function testXmlExport()
{
$export = new Doctrine_Export_Schema();
$export->exportSchema('schema.xml', 'xml', dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'models', $this->tables);
}
}
......@@ -20,7 +20,7 @@
*/
/**
* Doctrine_Import_Schema_Yml_TestCase
* Doctrine_Import_Schema_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
......@@ -30,7 +30,7 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_Import_Schema_Yml_TestCase extends Doctrine_UnitTestCase
class Doctrine_Import_Schema_TestCase extends Doctrine_UnitTestCase
{
public function testYmlImport()
{
......@@ -49,4 +49,22 @@ class Doctrine_Import_Schema_Yml_TestCase extends Doctrine_UnitTestCase
unlink('classes/Group.class.php');
}
}
public function testXmlImport()
{
$import = new Doctrine_Import_Schema();
$import->importSchema('schema.xml', 'xml', 'classes');
if ( ! file_exists('classes/User.class.php')) {
$this->fail();
} else {
unlink('classes/User.class.php');
}
if ( ! file_exists('classes/Group.class.php')) {
$this->fail();
} else {
unlink('classes/Group.class.php');
}
}
}
......@@ -79,9 +79,6 @@ foreach($models as $key => $file) {
}
}
}
//require_once dirname(__FILE__) . '/../models/location.php';
//require_once dirname(__FILE__) . '/../models/Blog.php';
//require_once dirname(__FILE__) . '/classes.php';
require_once dirname(__FILE__) . '/Test.php';
require_once dirname(__FILE__) . '/UnitTestCase.php';
......@@ -90,7 +87,6 @@ error_reporting(E_ALL | E_STRICT);
$test = new GroupTest('Doctrine Framework Unit Tests');
//TICKET test cases
$tickets = new GroupTest('Tickets tests');
$tickets->addTestCase(new Doctrine_Ticket_Njero_TestCase());
......@@ -306,11 +302,6 @@ $test->addTestCase(new Doctrine_RawSql_TestCase());
$test->addTestCase(new Doctrine_NewCore_TestCase());
//$test->addTestCase(new Doctrine_Import_Schema_Xml_TestCase());
//$test->addTestCase(new Doctrine_Export_Schema_Xml_TestCase());
$test->addTestCase(new Doctrine_Import_Schema_Yml_TestCase());
$test->addTestCase(new Doctrine_Export_Schema_Yml_TestCase());
$test->addTestCase(new Doctrine_Template_TestCase());
//$test->addTestCase(new Doctrine_Import_Builder_TestCase());
......@@ -339,6 +330,10 @@ $test->addTestCase(new Doctrine_Query_ApplyInheritance_TestCase());
$test->addTestCase(new Doctrine_Migration_TestCase());
$test->addTestCase(new Doctrine_Import_Schema_TestCase());
$test->addTestCase(new Doctrine_Export_Schema_TestCase());
class CliReporter extends HtmlReporter{
public function paintHeader(){
echo "Doctrine UnitTests\n";
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment