Changeset 3888
- Timestamp:
- 02/23/08 21:11:36 (17 months ago)
- Location:
- branches/0.10
- Files:
-
- 11 added
- 5 modified
-
lib/Doctrine.php (modified) (7 diffs)
-
models/ModelLoadingTest (added)
-
models/ModelLoadingTest/Aggressive (added)
-
models/ModelLoadingTest/Aggressive/Models.php (added)
-
models/ModelLoadingTest/Aggressive/MoreModels.php (added)
-
models/ModelLoadingTest/Conservative (added)
-
models/ModelLoadingTest/Conservative/BaseConservativeModelLoadingUser.php (added)
-
models/ModelLoadingTest/Conservative/ConservativeModelLoadingContact.php (added)
-
models/ModelLoadingTest/Conservative/ConservativeModelLoadingProfile.php (added)
-
models/ModelLoadingTest/Conservative/ConservativeModelLoadingUser.php (added)
-
tests/Base (added)
-
tests/BaseTestCase.php (added)
-
tests/Import/BuilderTestCase.php (modified) (1 diff)
-
tests/Import/SchemaTestCase.php (modified) (3 diffs)
-
tests/run.php (modified) (3 diffs)
-
tests/schema.yml (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.10/lib/Doctrine.php
r3887 r3888 469 469 private static $_loadedModelFiles = array(); 470 470 471 private static $_pathModels = array();472 473 471 /** 474 472 * _validators … … 490 488 } 491 489 490 /** 491 * getLoadedModelFiles 492 * 493 * Returns an array of all the loaded models and the path where each of them exists 494 * 495 * @return array 496 */ 492 497 public static function getLoadedModelFiles() 493 498 { 494 499 return self::$_loadedModelFiles; 495 }496 497 public static function getPathModels()498 {499 return self::$_pathModels;500 500 } 501 501 … … 555 555 $e = explode('.', $file->getFileName()); 556 556 if (end($e) === 'php' && strpos($file->getFileName(), '.inc') === false) { 557 $className = $e[0]; 557 558 558 559 if ($modelLoading == Doctrine::MODEL_LOADING_CONSERVATIVE) { 559 self::$_loadedModelFiles[$e[0]] = $file->getPathName(); 560 self::$_pathModels[$file->getPathName()][$e[0]] = $e[0]; 561 562 $loadedModels[] = $e[0]; 560 self::$_loadedModelFiles[$className] = $file->getPathName(); 561 562 $loadedModels[$className] = $className; 563 563 } else { 564 564 $declaredBefore = get_declared_classes(); … … 571 571 foreach ($foundClasses as $className) { 572 572 if (self::isValidModelClass($className)) { 573 $loadedModels[ ] = $className;573 $loadedModels[$className] = $className; 574 574 575 575 self::$_loadedModelFiles[$className] = $file->getPathName(); 576 self::$_pathModels[$file->getPathName()][$className] = $className;577 576 } 578 577 } … … 624 623 625 624 foreach ((array) $classes as $name) { 626 if (self::isValidModelClass($name) && ! in_array($name, $validModels)) {625 if (self::isValidModelClass($name) && ! in_array($name, $validModels)) { 627 626 $validModels[] = $name; 628 627 } … … 655 654 // - abstract classes 656 655 // - not a subclass of Doctrine_Record 657 // - don't have a setTableDefinition method 658 if (!$class->isAbstract() && 659 $class->isSubClassOf('Doctrine_Record') && 660 $class->hasMethod('setTableDefinition')) { 656 if ( ! $class->isAbstract() && $class->isSubClassOf('Doctrine_Record')) { 661 657 662 658 return true; … … 680 676 681 677 foreach ($loadedModels as $name) { 682 $model = new $name(); 683 $table = $model->getTable(); 678 $table = Doctrine::getTable($name); 684 679 685 680 if ($table->getTableName() == $tableName) { -
branches/0.10/tests/Import/BuilderTestCase.php
r3884 r3888 33 33 class Doctrine_Import_Builder_TestCase extends Doctrine_UnitTestCase 34 34 { 35 public function test BuildingOfRecord()35 public function testInheritanceGeneration() 36 36 { 37 $table = $this->conn->getTable('Phonenumber'); 37 $path = realpath(dirname(__FILE__) . '/../..') . '/models/test_generated'; 38 39 $import = new Doctrine_Import_Schema(); 40 $import->importSchema('schema.yml', 'yml', $path); 41 42 $models = Doctrine::loadModels($path, Doctrine::MODEL_LOADING_CONSERVATIVE); 43 44 $schemaTestInheritanceParent = new ReflectionClass('SchemaTestInheritanceParent'); 45 $schemaTestInheritanceChild1 = new ReflectionClass('SchemaTestInheritanceChild1'); 46 $schemaTestInheritanceChild2 = new ReflectionClass('SchemaTestInheritanceChild2'); 47 48 /* 49 $schemaTestInheritanceParentTable = new ReflectionClass('SchemaTestInheritanceParentTable'); 50 $schemaTestInheritanceChild1Table = new ReflectionClass('SchemaTestInheritanceChild1Table'); 51 $schemaTestInheritanceChild2Table = new ReflectionClass('SchemaTestInheritanceChild2Table'); 52 */ 53 54 $this->assertTrue($schemaTestInheritanceParent->isSubClassOf('BaseSchemaTestInheritanceParent')); 55 $this->assertTrue($schemaTestInheritanceChild1->isSubClassOf('BaseSchemaTestInheritanceChild1')); 56 $this->assertTrue($schemaTestInheritanceChild2->isSubClassOf('BaseSchemaTestInheritanceChild2')); 38 57 39 $builder = new Doctrine_Import_Builder(); 58 $this->assertTrue($schemaTestInheritanceChild1->isSubClassOf('SchemaTestInheritanceParent')); 59 $this->assertTrue($schemaTestInheritanceChild1->isSubClassOf('BaseSchemaTestInheritanceParent')); 40 60 41 $rel = $builder->buildRelationDefinition($table->getRelations()); 61 $this->assertTrue($schemaTestInheritanceChild2->isSubClassOf('SchemaTestInheritanceParent')); 62 $this->assertTrue($schemaTestInheritanceChild2->isSubClassOf('BaseSchemaTestInheritanceParent')); 63 $this->assertTrue($schemaTestInheritanceChild2->isSubClassOf('SchemaTestInheritanceChild1')); 64 $this->assertTrue($schemaTestInheritanceChild2->isSubClassOf('BaseSchemaTestInheritanceChild1')); 42 65 66 /* 67 $this->assertTrue($schemaTestInheritanceParentTable->isSubClassOf('Doctrine_Table')); 68 $this->assertTrue($schemaTestInheritanceChild1Table->isSubClassOf('SchemaTestInheritanceParentTable')); 69 $this->assertTrue($schemaTestInheritanceChild1Table->isSubClassOf('PackageSchemaTestInheritanceParentTable')); 70 */ 71 72 Doctrine_Lib::removeDirectories($path); 43 73 } 44 74 } -
branches/0.10/tests/Import/SchemaTestCase.php
r3884 r3888 38 38 public function testYmlImport() 39 39 { 40 $path = realpath(dirname(__FILE__) . '/../..') . '/models/test_generated'; 41 40 42 $import = new Doctrine_Import_Schema(); 41 $import->importSchema('schema.yml', 'yml', 'classes');43 $import->importSchema('schema.yml', 'yml', $path); 42 44 43 if ( ! file_exists( 'classes/User.php')) {45 if ( ! file_exists($path . '/SchemaTestUser.php')) { 44 46 $this->fail(); 45 47 } 46 48 47 if ( ! file_exists( 'classes/Profile.php')) {49 if ( ! file_exists($path . '/SchemaTestProfile.php')) { 48 50 $this->fail(); 49 51 } 52 53 Doctrine_Lib::removeDirectories($path); 50 54 } 51 55 … … 55 59 $array = $schema->buildSchema('schema.yml', 'yml'); 56 60 57 $model = $array[' User'];61 $model = $array['SchemaTestUser']; 58 62 59 63 $this->assertTrue(array_key_exists('connection', $model)); … … 68 72 $this->assertTrue(array_key_exists('options', $model) && is_array($model['options'])); 69 73 $this->assertTrue(array_key_exists('package', $model)); 74 $this->assertTrue(array_key_exists('inheritance', $model) && is_array($model['inheritance'])); 75 $this->assertTrue(array_key_exists('detect_relations', $model) && is_bool($model['detect_relations'])); 76 $this->assertTrue(array_key_exists('generate_accessors', $model) && is_bool($model['generate_accessors'])); 70 77 } 71 78 -
branches/0.10/tests/run.php
r3880 r3888 121 121 // Core 122 122 $core = new GroupTest('Core tests: Access, Configurable, Manager, Connection, Table, UnitOfWork, Collection, Hydrate, Tokenizer','core'); 123 $core->addTestCase(new Doctrine_Base_TestCase()); 123 124 $core->addTestCase(new Doctrine_Access_TestCase()); 124 125 //$core->addTestCase(new Doctrine_Configurable_TestCase()); … … 227 228 $record->addTestCase(new Doctrine_Record_Inheritance_TestCase()); 228 229 $record->addTestCase(new Doctrine_Record_Synchronize_TestCase()); 230 $record->addTestCase(new Doctrine_Import_Builder_TestCase()); 229 231 $test->addTestCase($record); 230 232 … … 243 245 244 246 $test->addTestCase(new Doctrine_Template_TestCase()); 245 246 //$test->addTestCase(new Doctrine_Import_Builder_TestCase());247 247 $test->addTestCase(new Doctrine_NestedSet_SingleRoot_TestCase()); 248 248 -
branches/0.10/tests/schema.yml
r3159 r3888 1 1 --- 2 User:2 SchemaTestUser: 3 3 actAs: [Timestampable] 4 4 columns: … … 11 11 password: 12 12 type: string(255) 13 Profile: 13 14 SchemaTestProfile: 14 15 actAs: [Timestampable] 15 16 columns: … … 27 28 type: string(255) 28 29 relations: 29 User:30 SchemaTestUser: 30 31 foreignType: one 31 Contact:32 SchemaTestContact: 32 33 foreignType: one 33 Contact: 34 35 SchemaTestContact: 34 36 actAs: [Timestampable] 35 37 columns: … … 40 42 name: 41 43 type: string(255) 42 Phonenumber: 44 45 SchemaTestPhonenumber: 43 46 actAs: [Timestampable] 44 47 columns: … … 52 55 type: integer(4) 53 56 relations: 54 Contact:57 SchemaTestContact: 55 58 foreignAlias: Phonenumbers 59 60 SchemaTestInheritanceParent: 61 package: Parent 62 columns: 63 id: 64 type: integer(4) 65 primary: true 66 autoincrement: true 67 name: 68 type: string(255) 69 type: 70 type: string(255) 71 options: 72 subclasses: [SchemaTestInheritanceChild1] 73 74 SchemaTestInheritanceChild1: 75 package: Child1 76 inheritance: 77 extends: SchemaTestInheritanceParent 78 keyField: type 79 keyValue: child1 80 81 SchemaTestInheritanceChild2: 82 package: Child2 83 inheritance: 84 extends: SchemaTestInheritanceChild1 85 keyField: type 86 keyValue: child2