From e360684d1bb525a5c470e1ccb01cadd760520755 Mon Sep 17 00:00:00 2001 From: meus Date: Sun, 2 Sep 2007 14:24:49 +0000 Subject: [PATCH] moved all models to trunk/models. removed some old invalid testcases --- models/Account.php | 10 + models/Address.php | 13 + models/Album.php | 11 + models/App.php | 13 + models/App_Category.php | 11 + models/App_User.php | 15 + models/Assignment.php | 8 + models/Auth.php | 14 + models/Author.php | 7 + models/BadlyNamed__Class.php | 8 + models/BarRecord.php | 13 + models/BoardWithPosition.php | 10 + models/Book.php | 10 + models/BooleanTest.php | 7 + models/CPK_Association.php | 7 + models/CPK_Test.php | 9 + models/CPK_Test2.php | 9 + models/CascadeDeleteRelatedTest.php | 20 + models/CascadeDeleteRelatedTest2.php | 15 + models/CascadeDeleteTest.php | 14 + models/CategoryWithPosition.php | 10 + models/CheckConstraintTest.php | 10 + models/Cms_Cateogry.php | 21 + .../Cms_CateogryLanguages.php | 20 - models/ColumnAliasTest.php | 12 + models/ConcreteEmail.php | 8 + models/ConcreteGroup.php | 8 + models/ConcreteGroupUser.php | 8 + models/ConcreteInheritanceTest.php | 18 + models/ConcreteUser.php | 9 + models/CoverageCodeN.php | 14 + models/CustomPK.php | 7 + models/CustomSequenceRecord.php | 9 + models/Data_File.php | 10 + models/DateTest.php | 7 + models/Description.php | 8 + models/Element.php | 12 + models/Email.php | 8 + models/Entity.php | 26 + models/EntityAddress.php | 9 + models/EntityReference.php | 11 + models/EnumTest.php | 12 + models/EnumTest2.php | 8 + models/EnumTest3.php | 7 + models/Error.php | 12 + models/EventListenerChainTest.php | 21 + models/EventListenerTest.php | 16 + models/ExpressionTest.php | 9 + models/FieldNameTest.php | 12 + models/File_Owner.php | 9 + models/FilterTest.php | 9 + models/FilterTest2.php | 7 + models/FooBarRecord.php | 9 + models/FooForeignlyOwned.php | 9 + models/FooForeignlyOwnedWithPK.php | 12 + models/FooLocallyOwned.php | 9 + {tests/Export/_files => models}/FooRecord.php | 144 +-- models/FooReferenceRecord.php | 11 + models/ForeignKeyTest.php | 24 + models/ForeignKeyTest2.php | 11 + models/Forum_Board.php | 13 + models/Forum_Category.php | 14 + models/Forum_Entry.php | 16 + models/Forum_Thread.php | 13 + models/Group.php | 13 + models/GroupUser.php | 10 + models/GzipTest.php | 6 + models/InheritanceTest.php | 19 + models/JC1.php | 8 + models/JC2.php | 8 + models/JC3.php | 8 + models/LiabilityCodeN.php | 14 + models/LocationI18n.php | 15 + models/Log_Entry.php | 10 + models/Log_Status.php | 6 + models/M2MTest.php | 16 + models/M2MTest2.php | 11 + models/MyGroup.php | 17 + models/MyOneThing.php | 10 + models/MyOtherThing.php | 10 + models/MyUser.php | 10 + models/MyUser2.php | 23 + models/MyUserGroup.php | 18 + models/MyUserOneThing.php | 7 + models/MyUserOtherThing.php | 7 + models/MysqlGroup.php | 10 + models/MysqlGroupMember.php | 10 + models/MysqlTestRecord.php | 11 + models/MysqlUser.php | 10 + models/NestReference.php | 9 + models/NestTest.php | 22 + models/NestedSetTest_SingleRootNode.php | 9 + models/NotNullTest.php | 7 + models/ORM_AccessControl.php | 12 + models/ORM_AccessControlsGroups.php | 9 + models/ORM_AccessGroup.php | 12 + models/ORM_TestEntry.php | 15 + models/ORM_TestItem.php | 13 + models/Package.php | 11 + models/PackageVersion.php | 12 + models/PackageVersionNotes.php | 13 + models/Phonenumber.php | 15 + models/Photo.php | 9 + models/Phototag.php | 7 + models/Policy.php | 15 + models/PolicyAsset.php | 16 + models/PolicyCodeN.php | 14 + models/PolicyN.php | 15 + models/QueryTest_Board.php | 27 + models/QueryTest_Category.php | 36 + models/QueryTest_Entry.php | 22 + models/QueryTest_Item.php | 10 + models/QueryTest_Rank.php | 20 + models/QueryTest_User.php | 20 + models/QueryTest_UserRank.php | 9 + models/RTC1.php | 10 + models/RTC2.php | 10 + models/RTC3.php | 11 + models/RTC4.php | 10 + models/RateN.php | 22 + models/Rec1.php | 15 + models/Rec2.php | 15 + models/RecordFilterTest.php | 16 + models/RecordHookTest.php | 46 + models/{location.php => Record_City.php} | 37 +- models/Record_Country.php | 11 + models/Record_District.php | 6 + models/RelationTest.php | 10 + models/RelationTestChild.php | 10 + models/ResourceReference.php | 8 + models/ResourceTask.php | 10 + models/ResourceType.php | 10 + models/Role.php | 13 + models/SelfRefTest.php | 14 + models/SequenceRecord.php | 8 + models/SerializeTest.php | 31 + models/SoftDeleteTest.php | 20 + models/Song.php | 8 + models/Tag.php | 9 + models/Task.php | 11 + models/TestMovie.php | 27 + models/TestMovieUserBookmark.php | 10 + models/TestMovieUserVote.php | 9 + models/TestRecord.php | 8 + models/TestUser.php | 21 + models/TreeLeaf.php | 14 + models/User.php | 37 + models/ValidatorTest.php | 15 + models/ValidatorTest_AddressModel.php | 18 + models/ValidatorTest_ClientModel.php | 15 + models/ValidatorTest_ClientToAddressModel.php | 15 + models/ValidatorTest_FootballPlayer.php | 8 + models/ValidatorTest_Person.php | 11 + models/VersioningTest.php | 13 + models/ZeroValueTest.php | 19 + models/mmrGroupUser_B.php | 9 + models/mmrGroupUser_C.php | 10 + models/mmrGroup_B.php | 14 + models/mmrGroup_C.php | 15 + models/mmrUser_B.php | 18 + tests/AuditLogTestCase.php | 12 - .../ColumnAggregationInheritanceTestCase.php | 15 - tests/ColumnAliasTestCase.php | 12 +- tests/EventListener/ChainTestCase.php | 20 - tests/EventListenerTestCase.php | 16 +- tests/Export/CheckConstraintTestCase.php | 9 - tests/Export/RecordTestCase.php | 86 -- tests/Export/ReporterTestCase.php | 6 - tests/ExpressionTestCase.php | 9 +- tests/IntegrityActionTestCase.php | 47 - tests/OneTableOneClassInheritanceTestCase.php | 16 - tests/Query/AggregateValueTestCase.php | 8 - tests/Query/ExpressionTestCase.php | 28 - tests/Record/HookTestCase.php | 67 -- tests/Record/LockTestCase.php | 28 - tests/Record/SaveBlankRecordTestCase.php | 58 -- tests/Record/SerializeUnserializeTestCase.php | 38 - tests/Record/ZeroValuesTestCase.php | 19 - tests/RecordFilterTestCase.php | 17 - tests/Relation/ManyToMany2TestCase.php | 66 -- tests/Relation/ManyToManyTestCase.php | 77 -- tests/Relation/OneToManyTestCase.php | 53 - tests/RelationTestCase.php | 17 - tests/SchemaTestCase.php | 5 +- tests/SequenceTestCase.php | 14 - tests/TemplateTestCase.php | 30 +- tests/Ticket/424BTestCase.php | 40 - tests/Ticket/424CTestCase.php | 42 - tests/Ticket330TestCase.php | 98 -- tests/Ticket337TestCase.php | 146 --- tests/Ticket343TestCase.php | 110 --- tests/TicketNjeroTestCase.php | 157 +-- tests/TreeStructureTestCase.php | 14 +- tests/classes.php | 902 ------------------ tests/run.php | 36 +- 195 files changed, 2137 insertions(+), 2400 deletions(-) create mode 100644 models/Account.php create mode 100644 models/Address.php create mode 100644 models/Album.php create mode 100644 models/App.php create mode 100644 models/App_Category.php create mode 100644 models/App_User.php create mode 100644 models/Assignment.php create mode 100644 models/Auth.php create mode 100644 models/Author.php create mode 100644 models/BadlyNamed__Class.php create mode 100644 models/BarRecord.php create mode 100644 models/BoardWithPosition.php create mode 100644 models/Book.php create mode 100644 models/BooleanTest.php create mode 100644 models/CPK_Association.php create mode 100644 models/CPK_Test.php create mode 100644 models/CPK_Test2.php create mode 100644 models/CascadeDeleteRelatedTest.php create mode 100644 models/CascadeDeleteRelatedTest2.php create mode 100644 models/CascadeDeleteTest.php create mode 100644 models/CategoryWithPosition.php create mode 100644 models/CheckConstraintTest.php create mode 100644 models/Cms_Cateogry.php rename tests/Export/_files2/model.php => models/Cms_CateogryLanguages.php (54%) create mode 100644 models/ColumnAliasTest.php create mode 100644 models/ConcreteEmail.php create mode 100644 models/ConcreteGroup.php create mode 100644 models/ConcreteGroupUser.php create mode 100644 models/ConcreteInheritanceTest.php create mode 100644 models/ConcreteUser.php create mode 100644 models/CoverageCodeN.php create mode 100644 models/CustomPK.php create mode 100644 models/CustomSequenceRecord.php create mode 100644 models/Data_File.php create mode 100644 models/DateTest.php create mode 100644 models/Description.php create mode 100644 models/Element.php create mode 100644 models/Email.php create mode 100644 models/Entity.php create mode 100644 models/EntityAddress.php create mode 100644 models/EntityReference.php create mode 100644 models/EnumTest.php create mode 100644 models/EnumTest2.php create mode 100644 models/EnumTest3.php create mode 100644 models/Error.php create mode 100644 models/EventListenerChainTest.php create mode 100644 models/EventListenerTest.php create mode 100644 models/ExpressionTest.php create mode 100644 models/FieldNameTest.php create mode 100644 models/File_Owner.php create mode 100644 models/FilterTest.php create mode 100644 models/FilterTest2.php create mode 100644 models/FooBarRecord.php create mode 100644 models/FooForeignlyOwned.php create mode 100644 models/FooForeignlyOwnedWithPK.php create mode 100644 models/FooLocallyOwned.php rename {tests/Export/_files => models}/FooRecord.php (57%) create mode 100644 models/FooReferenceRecord.php create mode 100644 models/ForeignKeyTest.php create mode 100644 models/ForeignKeyTest2.php create mode 100644 models/Forum_Board.php create mode 100644 models/Forum_Category.php create mode 100644 models/Forum_Entry.php create mode 100644 models/Forum_Thread.php create mode 100644 models/Group.php create mode 100644 models/GroupUser.php create mode 100644 models/GzipTest.php create mode 100644 models/InheritanceTest.php create mode 100644 models/JC1.php create mode 100644 models/JC2.php create mode 100644 models/JC3.php create mode 100644 models/LiabilityCodeN.php create mode 100644 models/LocationI18n.php create mode 100644 models/Log_Entry.php create mode 100644 models/Log_Status.php create mode 100644 models/M2MTest.php create mode 100644 models/M2MTest2.php create mode 100644 models/MyGroup.php create mode 100644 models/MyOneThing.php create mode 100644 models/MyOtherThing.php create mode 100644 models/MyUser.php create mode 100644 models/MyUser2.php create mode 100644 models/MyUserGroup.php create mode 100644 models/MyUserOneThing.php create mode 100644 models/MyUserOtherThing.php create mode 100644 models/MysqlGroup.php create mode 100644 models/MysqlGroupMember.php create mode 100644 models/MysqlTestRecord.php create mode 100644 models/MysqlUser.php create mode 100644 models/NestReference.php create mode 100644 models/NestTest.php create mode 100644 models/NestedSetTest_SingleRootNode.php create mode 100644 models/NotNullTest.php create mode 100644 models/ORM_AccessControl.php create mode 100644 models/ORM_AccessControlsGroups.php create mode 100644 models/ORM_AccessGroup.php create mode 100644 models/ORM_TestEntry.php create mode 100644 models/ORM_TestItem.php create mode 100644 models/Package.php create mode 100644 models/PackageVersion.php create mode 100644 models/PackageVersionNotes.php create mode 100644 models/Phonenumber.php create mode 100644 models/Photo.php create mode 100644 models/Phototag.php create mode 100644 models/Policy.php create mode 100644 models/PolicyAsset.php create mode 100644 models/PolicyCodeN.php create mode 100644 models/PolicyN.php create mode 100644 models/QueryTest_Board.php create mode 100644 models/QueryTest_Category.php create mode 100644 models/QueryTest_Entry.php create mode 100644 models/QueryTest_Item.php create mode 100644 models/QueryTest_Rank.php create mode 100644 models/QueryTest_User.php create mode 100644 models/QueryTest_UserRank.php create mode 100644 models/RTC1.php create mode 100644 models/RTC2.php create mode 100644 models/RTC3.php create mode 100644 models/RTC4.php create mode 100644 models/RateN.php create mode 100644 models/Rec1.php create mode 100644 models/Rec2.php create mode 100644 models/RecordFilterTest.php create mode 100644 models/RecordHookTest.php rename models/{location.php => Record_City.php} (51%) create mode 100644 models/Record_Country.php create mode 100644 models/Record_District.php create mode 100644 models/RelationTest.php create mode 100644 models/RelationTestChild.php create mode 100644 models/ResourceReference.php create mode 100644 models/ResourceTask.php create mode 100644 models/ResourceType.php create mode 100644 models/Role.php create mode 100644 models/SelfRefTest.php create mode 100644 models/SequenceRecord.php create mode 100644 models/SerializeTest.php create mode 100644 models/SoftDeleteTest.php create mode 100644 models/Song.php create mode 100644 models/Tag.php create mode 100644 models/Task.php create mode 100644 models/TestMovie.php create mode 100644 models/TestMovieUserBookmark.php create mode 100644 models/TestMovieUserVote.php create mode 100644 models/TestRecord.php create mode 100644 models/TestUser.php create mode 100644 models/TreeLeaf.php create mode 100644 models/User.php create mode 100644 models/ValidatorTest.php create mode 100644 models/ValidatorTest_AddressModel.php create mode 100644 models/ValidatorTest_ClientModel.php create mode 100644 models/ValidatorTest_ClientToAddressModel.php create mode 100644 models/ValidatorTest_FootballPlayer.php create mode 100644 models/ValidatorTest_Person.php create mode 100644 models/VersioningTest.php create mode 100644 models/ZeroValueTest.php create mode 100644 models/mmrGroupUser_B.php create mode 100644 models/mmrGroupUser_C.php create mode 100644 models/mmrGroup_B.php create mode 100644 models/mmrGroup_C.php create mode 100644 models/mmrUser_B.php delete mode 100644 tests/Ticket330TestCase.php delete mode 100644 tests/Ticket337TestCase.php delete mode 100644 tests/Ticket343TestCase.php delete mode 100644 tests/classes.php diff --git a/models/Account.php b/models/Account.php new file mode 100644 index 000000000..6863cae85 --- /dev/null +++ b/models/Account.php @@ -0,0 +1,10 @@ +hasColumn('entity_id', 'integer'); + $this->hasColumn('amount', 'integer'); + } +} + diff --git a/models/Address.php b/models/Address.php new file mode 100644 index 000000000..9d423c30f --- /dev/null +++ b/models/Address.php @@ -0,0 +1,13 @@ +hasMany('User', array('local' => 'address_id', + 'foreign' => 'user_id', + 'refClass' => 'EntityAddress')); + } + public function setTableDefinition() { + $this->hasColumn('address', 'string', 200); + } +} diff --git a/models/Album.php b/models/Album.php new file mode 100644 index 000000000..918eaa32c --- /dev/null +++ b/models/Album.php @@ -0,0 +1,11 @@ +ownsMany('Song', 'Song.album_id'); + } + public function setTableDefinition() { + $this->hasColumn('user_id', 'integer'); + $this->hasColumn('name', 'string',20); + } +} + diff --git a/models/App.php b/models/App.php new file mode 100644 index 000000000..7e5952415 --- /dev/null +++ b/models/App.php @@ -0,0 +1,13 @@ +hasColumn('name', 'string', 32); + $this->hasColumn('user_id', 'integer', 11); + $this->hasColumn('app_category_id', 'integer', 11); + } + public function setUp() { + $this->hasOne('User', 'User.id'); + $this->hasMany('App_Category as Category', 'App_Category.id'); + } +} + diff --git a/models/App_Category.php b/models/App_Category.php new file mode 100644 index 000000000..e61c25fa8 --- /dev/null +++ b/models/App_Category.php @@ -0,0 +1,11 @@ +hasColumn('name', 'string', 32); + $this->hasColumn('parent_id', 'integer'); + } + public function setUp() { + $this->hasMany('App', 'App.app_category_id'); + $this->hasMany('App_Category as Parent', 'App_Category.parent_id'); + } +} diff --git a/models/App_User.php b/models/App_User.php new file mode 100644 index 000000000..f570269bb --- /dev/null +++ b/models/App_User.php @@ -0,0 +1,15 @@ +hasColumn('first_name', 'string', 32); + $this->hasColumn('last_name', 'string', 32); + $this->hasColumn('email', 'string', 128, 'email'); + $this->hasColumn('username', 'string', 16, 'unique, nospace'); + $this->hasColumn('password', 'string', 128, 'notblank'); + $this->hasColumn('country', 'string', 2, 'country'); + $this->hasColumn('zipcode', 'string', 9, 'nospace'); + } + public function setUp() { + $this->hasMany('App', 'App.user_id'); + } +} diff --git a/models/Assignment.php b/models/Assignment.php new file mode 100644 index 000000000..3d2f8b722 --- /dev/null +++ b/models/Assignment.php @@ -0,0 +1,8 @@ +hasColumn('task_id', 'integer'); + $this->hasColumn('resource_id', 'integer'); + } +} + diff --git a/models/Auth.php b/models/Auth.php new file mode 100644 index 000000000..23df462ae --- /dev/null +++ b/models/Auth.php @@ -0,0 +1,14 @@ +hasColumn('roleid', 'integer', 10); + $this->hasColumn('name', 'string', 50); + } + public function setUp() + { + $this->hasOne('Role', array('local' => 'roleid', 'foreign' => 'id')); + } +} + diff --git a/models/Author.php b/models/Author.php new file mode 100644 index 000000000..0c294d2ff --- /dev/null +++ b/models/Author.php @@ -0,0 +1,7 @@ +hasColumn('book_id', 'integer'); + $this->hasColumn('name', 'string',20); + } +} diff --git a/models/BadlyNamed__Class.php b/models/BadlyNamed__Class.php new file mode 100644 index 000000000..75c793370 --- /dev/null +++ b/models/BadlyNamed__Class.php @@ -0,0 +1,8 @@ +setTableName('bar'); + $this->hasColumn('name', 'string', 200); + } + public function setUp() + { + $this->hasMany('FooRecord as Foo', array('local' => 'barId', 'foreign' => 'fooId', 'refClass' => 'FooBarRecord')); + } +} diff --git a/models/BoardWithPosition.php b/models/BoardWithPosition.php new file mode 100644 index 000000000..0a23c8839 --- /dev/null +++ b/models/BoardWithPosition.php @@ -0,0 +1,10 @@ +hasColumn('position', 'integer'); + $this->hasColumn('category_id', 'integer'); + } + public function setUp() { + $this->hasOne('CategoryWithPosition as Category', 'BoardWithPosition.category_id'); + } +} diff --git a/models/Book.php b/models/Book.php new file mode 100644 index 000000000..6f27bf38b --- /dev/null +++ b/models/Book.php @@ -0,0 +1,10 @@ +ownsMany('Author', 'Author.book_id'); + } + public function setTableDefinition() { + $this->hasColumn('user_id', 'integer'); + $this->hasColumn('name', 'string',20); + } +} diff --git a/models/BooleanTest.php b/models/BooleanTest.php new file mode 100644 index 000000000..748a6fa2b --- /dev/null +++ b/models/BooleanTest.php @@ -0,0 +1,7 @@ +hasColumn('is_working', 'boolean'); + $this->hasColumn('is_working_notnull', 'boolean', 1, array('default' => false, 'notnull' => true)); + } +} diff --git a/models/CPK_Association.php b/models/CPK_Association.php new file mode 100644 index 000000000..df9de93d8 --- /dev/null +++ b/models/CPK_Association.php @@ -0,0 +1,7 @@ +hasColumn('test1_id', 'integer', 11, 'primary'); + $this->hasColumn('test2_id', 'integer', 11, 'primary'); + } +} diff --git a/models/CPK_Test.php b/models/CPK_Test.php new file mode 100644 index 000000000..a850342bb --- /dev/null +++ b/models/CPK_Test.php @@ -0,0 +1,9 @@ +hasColumn('name', 'string', 255); + } + public function setUp() { + $this->hasMany('CPK_Test2 as Test', 'CPK_Association.test2_id'); + } +} diff --git a/models/CPK_Test2.php b/models/CPK_Test2.php new file mode 100644 index 000000000..9744ac03f --- /dev/null +++ b/models/CPK_Test2.php @@ -0,0 +1,9 @@ +hasColumn('name', 'string', 255); + } + public function setUp() { + $this->hasMany('CPK_Test as Test', 'CPK_Association.test1_id'); + } +} diff --git a/models/CascadeDeleteRelatedTest.php b/models/CascadeDeleteRelatedTest.php new file mode 100644 index 000000000..15c34f295 --- /dev/null +++ b/models/CascadeDeleteRelatedTest.php @@ -0,0 +1,20 @@ +hasColumn('name', 'string'); + $this->hasColumn('cscd_id', 'integer'); + } + public function setUp() + { + $this->hasOne('CascadeDeleteTest', array('local' => 'cscd_id', + 'foreign' => 'id', + 'onDelete' => 'CASCADE', + 'onUpdate' => 'SET NULL')); + + $this->hasMany('CascadeDeleteRelatedTest2 as Related', + array('local' => 'id', + 'foreign' => 'cscd_id')); + } +} diff --git a/models/CascadeDeleteRelatedTest2.php b/models/CascadeDeleteRelatedTest2.php new file mode 100644 index 000000000..46049e104 --- /dev/null +++ b/models/CascadeDeleteRelatedTest2.php @@ -0,0 +1,15 @@ +hasColumn('name', 'string'); + $this->hasColumn('cscd_id', 'integer'); + } + public function setUp() + { + $this->hasOne('CascadeDeleteRelatedTest', array('local' => 'cscd_id', + 'foreign' => 'id', + 'onDelete' => 'SET NULL')); + } +} diff --git a/models/CascadeDeleteTest.php b/models/CascadeDeleteTest.php new file mode 100644 index 000000000..9cd6698d3 --- /dev/null +++ b/models/CascadeDeleteTest.php @@ -0,0 +1,14 @@ +hasColumn('name', 'string'); + } + public function setUp() + { + $this->hasMany('CascadeDeleteRelatedTest as Related', + array('local' => 'id', + 'foreign' => 'cscd_id')); + } +} diff --git a/models/CategoryWithPosition.php b/models/CategoryWithPosition.php new file mode 100644 index 000000000..53dd2f8ce --- /dev/null +++ b/models/CategoryWithPosition.php @@ -0,0 +1,10 @@ +hasColumn('position', 'integer'); + $this->hasColumn('name', 'string', 255); + } + public function setUp() { + $this->ownsMany('BoardWithPosition as Boards', 'BoardWithPosition.category_id'); + } +} diff --git a/models/CheckConstraintTest.php b/models/CheckConstraintTest.php new file mode 100644 index 000000000..a1ed16357 --- /dev/null +++ b/models/CheckConstraintTest.php @@ -0,0 +1,10 @@ +hasColumn('price', 'decimal', 2, array('max' => 5000, 'min' => 100)); + $this->hasColumn('discounted_price', 'decimal', 2); + $this->check('price > discounted_price'); + } +} diff --git a/models/Cms_Cateogry.php b/models/Cms_Cateogry.php new file mode 100644 index 000000000..e4f31c56a --- /dev/null +++ b/models/Cms_Cateogry.php @@ -0,0 +1,21 @@ +ownsMany('Cms_CategoryLanguages as langs', array('local' => 'id', 'foreign' => 'category_id')); + } + + public function setTableDefinition() + { + $this->hasColumn('created', 'timestamp'); + $this->hasColumn('parent', 'integer', 11); + $this->hasColumn('position', 'integer', 3); + $this->hasColumn('active', 'integer', 11); + $this->option('collate', 'utf8_unicode_ci'); + $this->option('charset', 'utf8'); + $this->option('type', 'INNODB'); + $this->index('index_parent', array('fields' => array('parent'))); + } +} diff --git a/tests/Export/_files2/model.php b/models/Cms_CateogryLanguages.php similarity index 54% rename from tests/Export/_files2/model.php rename to models/Cms_CateogryLanguages.php index 6469693e9..5a0f0bb6f 100644 --- a/tests/Export/_files2/model.php +++ b/models/Cms_CateogryLanguages.php @@ -19,23 +19,3 @@ class Cms_CategoryLanguages extends Doctrine_Record $this->index('index_language', array('fields' => array('language_id'))); } } -class Cms_Category extends Doctrine_Record -{ - - public function setUp() - { - $this->ownsMany('Cms_CategoryLanguages as langs', array('local' => 'id', 'foreign' => 'category_id')); - } - - public function setTableDefinition() - { - $this->hasColumn('created', 'timestamp'); - $this->hasColumn('parent', 'integer', 11); - $this->hasColumn('position', 'integer', 3); - $this->hasColumn('active', 'integer', 11); - $this->option('collate', 'utf8_unicode_ci'); - $this->option('charset', 'utf8'); - $this->option('type', 'INNODB'); - $this->index('index_parent', array('fields' => array('parent'))); - } -} diff --git a/models/ColumnAliasTest.php b/models/ColumnAliasTest.php new file mode 100644 index 000000000..633eaede1 --- /dev/null +++ b/models/ColumnAliasTest.php @@ -0,0 +1,12 @@ +hasColumn('column1 as alias1', 'string', 200); + $this->hasColumn('column2 as alias2', 'integer', 11); + } + public function setUp() + { + } +} diff --git a/models/ConcreteEmail.php b/models/ConcreteEmail.php new file mode 100644 index 000000000..99532aab0 --- /dev/null +++ b/models/ConcreteEmail.php @@ -0,0 +1,8 @@ +loadTemplate('EmailTemplate'); + } +} diff --git a/models/ConcreteGroup.php b/models/ConcreteGroup.php new file mode 100644 index 000000000..447c06f7e --- /dev/null +++ b/models/ConcreteGroup.php @@ -0,0 +1,8 @@ +loadTemplate('GroupTemplate'); + } +} diff --git a/models/ConcreteGroupUser.php b/models/ConcreteGroupUser.php new file mode 100644 index 000000000..79cc1203b --- /dev/null +++ b/models/ConcreteGroupUser.php @@ -0,0 +1,8 @@ +loadTemplate('GroupUserTemplate'); + } +} diff --git a/models/ConcreteInheritanceTest.php b/models/ConcreteInheritanceTest.php new file mode 100644 index 000000000..24a454ac0 --- /dev/null +++ b/models/ConcreteInheritanceTest.php @@ -0,0 +1,18 @@ +hasColumn('name', 'string'); + } +} + +class ConcreteInheritanceTestChild extends ConcreteInheritanceTestParent +{ + public function setTableDefinition() + { + $this->hasColumn('age', 'integer'); + + parent::setTableDefinition(); + } +} diff --git a/models/ConcreteUser.php b/models/ConcreteUser.php new file mode 100644 index 000000000..12a659d04 --- /dev/null +++ b/models/ConcreteUser.php @@ -0,0 +1,9 @@ +loadTemplate('UserTemplate'); + } +} + diff --git a/models/CoverageCodeN.php b/models/CoverageCodeN.php new file mode 100644 index 000000000..fd62d172f --- /dev/null +++ b/models/CoverageCodeN.php @@ -0,0 +1,14 @@ +setTableName('coverage_codes'); + $this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true)); + $this->hasColumn('code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,)); + $this->hasColumn('description', 'string', 4000, array ( 'notnull' => true, 'notblank' => true,)); + } + + public function setUp(){ +# $this->index('code', array('fields' => 'code')); + } +} diff --git a/models/CustomPK.php b/models/CustomPK.php new file mode 100644 index 000000000..e136136de --- /dev/null +++ b/models/CustomPK.php @@ -0,0 +1,7 @@ +hasColumn('uid', 'integer',11, 'autoincrement|primary'); + $this->hasColumn('name', 'string',255); + } +} diff --git a/models/CustomSequenceRecord.php b/models/CustomSequenceRecord.php new file mode 100644 index 000000000..4dd147fff --- /dev/null +++ b/models/CustomSequenceRecord.php @@ -0,0 +1,9 @@ +hasColumn('id', 'integer', null, array('primary', 'sequence' => 'custom_seq')); + $this->hasColumn('name', 'string'); + } +} + diff --git a/models/Data_File.php b/models/Data_File.php new file mode 100644 index 000000000..b65abb109 --- /dev/null +++ b/models/Data_File.php @@ -0,0 +1,10 @@ +hasColumn('filename', 'string'); + $this->hasColumn('file_owner_id', 'integer'); + } + public function setUp() { + $this->hasOne('File_Owner', 'Data_File.file_owner_id'); + } +} diff --git a/models/DateTest.php b/models/DateTest.php new file mode 100644 index 000000000..424664198 --- /dev/null +++ b/models/DateTest.php @@ -0,0 +1,7 @@ +hasColumn('date', 'date', 20); + } +} + diff --git a/models/Description.php b/models/Description.php new file mode 100644 index 000000000..fd9bada28 --- /dev/null +++ b/models/Description.php @@ -0,0 +1,8 @@ +hasColumn('description', 'string',3000); + $this->hasColumn('file_md5', 'string',32); + } +} + diff --git a/models/Element.php b/models/Element.php new file mode 100644 index 000000000..e4317e179 --- /dev/null +++ b/models/Element.php @@ -0,0 +1,12 @@ +hasColumn('name', 'string', 100); + $this->hasColumn('parent_id', 'integer'); + } + public function setUp() { + $this->hasMany('Element as Child', 'Child.parent_id'); + $this->hasOne('Element as Parent', 'Element.parent_id'); + } +} + diff --git a/models/Email.php b/models/Email.php new file mode 100644 index 000000000..0ba31194e --- /dev/null +++ b/models/Email.php @@ -0,0 +1,8 @@ +hasColumn('address', 'string', 150, 'email|unique'); + } +} diff --git a/models/Entity.php b/models/Entity.php new file mode 100644 index 000000000..0e5cc0741 --- /dev/null +++ b/models/Entity.php @@ -0,0 +1,26 @@ +ownsOne('Email', array('local' => 'email_id')); + $this->hasMany('Phonenumber', array('local' => 'id', 'foreign' => 'entity_id')); + $this->ownsOne('Account', array('foreign' => 'entity_id')); + $this->hasMany('Entity', array('local' => 'entity1', + 'refClass' => 'EntityReference', + 'foreign' => 'entity2', + 'equal' => true)); + } + public function setTableDefinition() + { + $this->hasColumn('id', 'integer',20, 'autoincrement|primary'); + $this->hasColumn('name', 'string',50); + $this->hasColumn('loginname', 'string',20, array('unique')); + $this->hasColumn('password', 'string',16); + $this->hasColumn('type', 'integer',1); + $this->hasColumn('created', 'integer',11); + $this->hasColumn('updated', 'integer',11); + $this->hasColumn('email_id', 'integer'); + $this->setSubclasses(array("User" => array("type" => 0), "Group" => array("type" => 1))); + } +} diff --git a/models/EntityAddress.php b/models/EntityAddress.php new file mode 100644 index 000000000..c9e7af5a4 --- /dev/null +++ b/models/EntityAddress.php @@ -0,0 +1,9 @@ +hasColumn('user_id', 'integer', null, array('primary' => true)); + $this->hasColumn('address_id', 'integer', null, array('primary' => true)); + } +} diff --git a/models/EntityReference.php b/models/EntityReference.php new file mode 100644 index 000000000..093dd0554 --- /dev/null +++ b/models/EntityReference.php @@ -0,0 +1,11 @@ +hasColumn('entity1', 'integer', null, 'primary'); + $this->hasColumn('entity2', 'integer', null, 'primary'); + //$this->setPrimaryKey(array('entity1', 'entity2')); + } +} + diff --git a/models/EnumTest.php b/models/EnumTest.php new file mode 100644 index 000000000..12b12abed --- /dev/null +++ b/models/EnumTest.php @@ -0,0 +1,12 @@ +hasColumn('status', 'enum', 11, array('values' => array('open', 'verified', 'closed'))); + $this->hasColumn('text', 'string'); + } + public function setUp() { + $this->hasMany('EnumTest2 as Enum2', array('local' => 'id', 'foreign' => 'enum_test_id')); + $this->hasMany('EnumTest3 as Enum3', array('local' => 'text', 'foreign' => 'text')); + } +} diff --git a/models/EnumTest2.php b/models/EnumTest2.php new file mode 100644 index 000000000..5c7325921 --- /dev/null +++ b/models/EnumTest2.php @@ -0,0 +1,8 @@ +hasColumn('status', 'enum', 11, array('values' => array('open', 'verified', 'closed'))); + $this->hasColumn('enum_test_id', 'integer'); + } +} diff --git a/models/EnumTest3.php b/models/EnumTest3.php new file mode 100644 index 000000000..0dc93a76e --- /dev/null +++ b/models/EnumTest3.php @@ -0,0 +1,7 @@ +hasColumn('text', 'string', 10, array('primary' => true)); + } +} diff --git a/models/Error.php b/models/Error.php new file mode 100644 index 000000000..76f2cfb2e --- /dev/null +++ b/models/Error.php @@ -0,0 +1,12 @@ +ownsMany('Description', 'Description.file_md5', 'file_md5'); + } + public function setTableDefinition() { + $this->hasColumn('message', 'string',200); + $this->hasColumn('code', 'integer',11); + $this->hasColumn('file_md5', 'string',32, 'primary'); + } +} + diff --git a/models/EventListenerChainTest.php b/models/EventListenerChainTest.php new file mode 100644 index 000000000..8a235deba --- /dev/null +++ b/models/EventListenerChainTest.php @@ -0,0 +1,21 @@ +hasColumn('name', 'string', 100); + } + public function setUp() { + $chain = new Doctrine_EventListener_Chain(); + $chain->add(new Doctrine_EventListener_TestA()); + $chain->add(new Doctrine_EventListener_TestB()); + } +} + +class Doctrine_EventListener_TestA extends Doctrine_EventListener +{ + +} +class Doctrine_EventListener_TestB extends Doctrine_EventListener +{ + +} diff --git a/models/EventListenerTest.php b/models/EventListenerTest.php new file mode 100644 index 000000000..0a4f25c1d --- /dev/null +++ b/models/EventListenerTest.php @@ -0,0 +1,16 @@ +hasColumn("name", "string", 100); + $this->hasColumn("password", "string", 8); + } + public function setUp() { + //$this->attribute(Doctrine::ATTR_LISTENER, new Doctrine_EventListener_AccessorInvoker()); + } + public function getName($name) { + return strtoupper($name); + } + public function setPassword($password) { + return md5($password); + } +} diff --git a/models/ExpressionTest.php b/models/ExpressionTest.php new file mode 100644 index 000000000..cab1d2ad2 --- /dev/null +++ b/models/ExpressionTest.php @@ -0,0 +1,9 @@ +hasColumn('name', 'string'); + $this->hasColumn('amount', 'integer'); + } +} diff --git a/models/FieldNameTest.php b/models/FieldNameTest.php new file mode 100644 index 000000000..e8612b707 --- /dev/null +++ b/models/FieldNameTest.php @@ -0,0 +1,12 @@ +hasColumn('someColumn', 'string', 200, array('default' => 'some string')); + $this->hasColumn('someEnum', 'enum', 4, array('default' => 'php', 'values' => array('php', 'java', 'python'))); + $this->hasColumn('someArray', 'array', 100, array('default' => array())); + $this->hasColumn('someObject', 'object', 200, array('default' => new stdClass)); + $this->hasColumn('someInt', 'integer', 20, array('default' => 11)); + } +} diff --git a/models/File_Owner.php b/models/File_Owner.php new file mode 100644 index 000000000..7f2379c98 --- /dev/null +++ b/models/File_Owner.php @@ -0,0 +1,9 @@ +hasColumn('name', 'string', 255); + } + public function setUp() { + $this->hasOne('Data_File', 'Data_File.file_owner_id'); + } +} diff --git a/models/FilterTest.php b/models/FilterTest.php new file mode 100644 index 000000000..df0cb69a9 --- /dev/null +++ b/models/FilterTest.php @@ -0,0 +1,9 @@ +hasColumn('name', 'string',100); + } + public function setUp() { + $this->ownsMany('FilterTest2 as filtered', 'FilterTest2.test1_id'); + } +} diff --git a/models/FilterTest2.php b/models/FilterTest2.php new file mode 100644 index 000000000..4ceb5e52d --- /dev/null +++ b/models/FilterTest2.php @@ -0,0 +1,7 @@ +hasColumn('name', 'string',100); + $this->hasColumn('test1_id', 'integer'); + } +} diff --git a/models/FooBarRecord.php b/models/FooBarRecord.php new file mode 100644 index 000000000..d32ec1cd5 --- /dev/null +++ b/models/FooBarRecord.php @@ -0,0 +1,9 @@ +hasColumn('fooId', 'integer', null, array('primary' => true)); + $this->hasColumn('barId', 'integer', null, array('primary' => true)); + } +} diff --git a/models/FooForeignlyOwned.php b/models/FooForeignlyOwned.php new file mode 100644 index 000000000..6593d5d4a --- /dev/null +++ b/models/FooForeignlyOwned.php @@ -0,0 +1,9 @@ +hasColumn('name', 'string', 200); + $this->hasColumn('fooId', 'integer'); + } +} diff --git a/models/FooForeignlyOwnedWithPK.php b/models/FooForeignlyOwnedWithPK.php new file mode 100644 index 000000000..af34912de --- /dev/null +++ b/models/FooForeignlyOwnedWithPK.php @@ -0,0 +1,12 @@ +hasColumn('name', 'string', 200); + } + public function setUp() + { + $this->hasOne('FooRecord', array('local' => 'id', 'foreign' => 'id')); + } +} diff --git a/models/FooLocallyOwned.php b/models/FooLocallyOwned.php new file mode 100644 index 000000000..a30a229f4 --- /dev/null +++ b/models/FooLocallyOwned.php @@ -0,0 +1,9 @@ +hasColumn('name', 'string', 200); + } +} + diff --git a/tests/Export/_files/FooRecord.php b/models/FooRecord.php similarity index 57% rename from tests/Export/_files/FooRecord.php rename to models/FooRecord.php index 1709ef4bd..2e39dd781 100644 --- a/tests/Export/_files/FooRecord.php +++ b/models/FooRecord.php @@ -1,101 +1,43 @@ -setTableName('foo'); - - $this->hasColumn('name', 'string', 200, array('notnull' => true)); - $this->hasColumn('parent_id', 'integer'); - $this->hasColumn('local_foo', 'integer'); - } - public function setUp() - { - $this->hasMany('FooRecord as FooFriend', array('local' => 'foo1', - 'foreign' => 'foo2', - 'equal' => true, - 'refClass' => 'FooReferenceRecord', - )); - - $this->hasMany('FooRecord as FooParents', array('local' => 'foo1', - 'foreign' => 'foo2', - 'refClass' => 'FooReferenceRecord', - 'onDelete' => 'RESTRICT', - )); - - $this->hasMany('FooRecord as FooChildren', array('local' => 'foo2', - 'foreign' => 'foo1', - 'refClass' => 'FooReferenceRecord', - )); - - $this->hasMany('FooRecord as Children', array('local' => 'id', 'foreign' => 'parent_id')); - - $this->hasOne('FooRecord as Parent', array('local' => 'parent_id', 'foreign' => 'id', 'onDelete' => 'CASCADE')); - $this->hasOne('FooForeignlyOwnedWithPk', array('local' => 'id', 'foreign' => 'id', 'constraint' => true)); - $this->hasOne('FooLocallyOwned', array('local' => 'local_foo', 'onDelete' => 'RESTRICT')); - - $this->hasMany('BarRecord as Bar', array('local' => 'fooId', - 'foreign' => 'barId', - 'refClass' => 'FooBarRecord', - 'onUpdate' => 'RESTRICT')); - - } -} -class FooReferenceRecord extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('foo_reference'); - - $this->hasColumn('foo1', 'integer', null, array('primary' => true)); - $this->hasColumn('foo2', 'integer', null, array('primary' => true)); - } -} - -class FooBarRecord extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('fooId', 'integer', null, array('primary' => true)); - $this->hasColumn('barId', 'integer', null, array('primary' => true)); - } -} -class BarRecord extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('bar'); - $this->hasColumn('name', 'string', 200); - } - public function setUp() - { - $this->hasMany('FooRecord as Foo', array('local' => 'barId', 'foreign' => 'fooId', 'refClass' => 'FooBarRecord')); - } -} -class FooLocallyOwned extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', 200); - } -} -class FooForeignlyOwned extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', 200); - $this->hasColumn('fooId', 'integer'); - } -} -class FooForeignlyOwnedWithPk extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', 200); - } - public function setUp() - { - $this->hasOne('FooRecord', array('local' => 'id', 'foreign' => 'id')); - } -} - +setTableName('foo'); + + $this->hasColumn('name', 'string', 200, array('notnull' => true)); + $this->hasColumn('parent_id', 'integer'); + $this->hasColumn('local_foo', 'integer'); + } + public function setUp() + { + $this->hasMany('FooRecord as FooFriend', array('local' => 'foo1', + 'foreign' => 'foo2', + 'equal' => true, + 'refClass' => 'FooReferenceRecord', + )); + + $this->hasMany('FooRecord as FooParents', array('local' => 'foo1', + 'foreign' => 'foo2', + 'refClass' => 'FooReferenceRecord', + 'onDelete' => 'RESTRICT', + )); + + $this->hasMany('FooRecord as FooChildren', array('local' => 'foo2', + 'foreign' => 'foo1', + 'refClass' => 'FooReferenceRecord', + )); + + $this->hasMany('FooRecord as Children', array('local' => 'id', 'foreign' => 'parent_id')); + + $this->hasOne('FooRecord as Parent', array('local' => 'parent_id', 'foreign' => 'id', 'onDelete' => 'CASCADE')); + $this->hasOne('FooForeignlyOwnedWithPk', array('local' => 'id', 'foreign' => 'id', 'constraint' => true)); + $this->hasOne('FooLocallyOwned', array('local' => 'local_foo', 'onDelete' => 'RESTRICT')); + + $this->hasMany('BarRecord as Bar', array('local' => 'fooId', + 'foreign' => 'barId', + 'refClass' => 'FooBarRecord', + 'onUpdate' => 'RESTRICT')); + + } +} diff --git a/models/FooReferenceRecord.php b/models/FooReferenceRecord.php new file mode 100644 index 000000000..fb378065f --- /dev/null +++ b/models/FooReferenceRecord.php @@ -0,0 +1,11 @@ +setTableName('foo_reference'); + + $this->hasColumn('foo1', 'integer', null, array('primary' => true)); + $this->hasColumn('foo2', 'integer', null, array('primary' => true)); + } +} diff --git a/models/ForeignKeyTest.php b/models/ForeignKeyTest.php new file mode 100644 index 000000000..69f618ac1 --- /dev/null +++ b/models/ForeignKeyTest.php @@ -0,0 +1,24 @@ +hasColumn('name', 'string', null); + $this->hasColumn('code', 'integer', 4); + $this->hasColumn('content', 'string', 4000); + $this->hasColumn('parent_id', 'integer'); + + $this->hasOne('ForeignKeyTest as Parent', + array('local' => 'parent_id', + 'foreign' => 'id', + 'onDelete' => 'CASCADE', + 'onUpdate' => 'RESTRICT') + ); + + $this->hasMany('ForeignKeyTest as Children', + 'ForeignKeyTest.parent_id'); + + $this->option('type', 'INNODB'); + + } +} diff --git a/models/ForeignKeyTest2.php b/models/ForeignKeyTest2.php new file mode 100644 index 000000000..ef325e791 --- /dev/null +++ b/models/ForeignKeyTest2.php @@ -0,0 +1,11 @@ +hasColumn('name', 'string', null); + $this->hasColumn('foreignkey', 'integer'); + + $this->hasOne('ForeignKeyTest', 'ForeignKeyTest2.foreignkey'); + } +} diff --git a/models/Forum_Board.php b/models/Forum_Board.php new file mode 100644 index 000000000..196bc6544 --- /dev/null +++ b/models/Forum_Board.php @@ -0,0 +1,13 @@ +hasColumn('category_id', 'integer', 10); + $this->hasColumn('name', 'string', 100); + $this->hasColumn('description', 'string', 5000); + } + public function setUp() { + $this->hasOne('Forum_Category as Category', 'Forum_Board.category_id'); + $this->ownsMany('Forum_Thread as Threads', 'Forum_Thread.board_id'); + } +} + diff --git a/models/Forum_Category.php b/models/Forum_Category.php new file mode 100644 index 000000000..5f635bb1f --- /dev/null +++ b/models/Forum_Category.php @@ -0,0 +1,14 @@ +hasColumn('root_category_id', 'integer', 10); + $this->hasColumn('parent_category_id', 'integer', 10); + $this->hasColumn('name', 'string', 50); + $this->hasColumn('description', 'string', 99999); + } + public function setUp() { + $this->hasMany('Forum_Category as Subcategory', 'Subcategory.parent_category_id'); + $this->hasOne('Forum_Category as Parent', 'Forum_Category.parent_category_id'); + $this->hasOne('Forum_Category as Rootcategory', 'Forum_Category.root_category_id'); + } +} diff --git a/models/Forum_Entry.php b/models/Forum_Entry.php new file mode 100644 index 000000000..ccccb8340 --- /dev/null +++ b/models/Forum_Entry.php @@ -0,0 +1,16 @@ +hasColumn('author', 'string', 50); + $this->hasColumn('topic', 'string', 100); + $this->hasColumn('message', 'string', 99999); + $this->hasColumn('parent_entry_id', 'integer', 10); + $this->hasColumn('thread_id', 'integer', 10); + $this->hasColumn('date', 'integer', 10); + } + public function setUp() { + $this->hasOne('Forum_Entry as Parent', 'Forum_Entry.parent_entry_id'); + $this->hasOne('Forum_Thread as Thread', 'Forum_Entry.thread_id'); + } +} + diff --git a/models/Forum_Thread.php b/models/Forum_Thread.php new file mode 100644 index 000000000..6911f3dec --- /dev/null +++ b/models/Forum_Thread.php @@ -0,0 +1,13 @@ +hasColumn('board_id', 'integer', 10); + $this->hasColumn('updated', 'integer', 10); + $this->hasColumn('closed', 'integer', 1); + } + public function setUp() { + $this->hasOne('Forum_Board as Board', 'Forum_Thread.board_id'); + $this->ownsMany('Forum_Entry as Entries', 'Forum_Entry.thread_id'); + } +} + diff --git a/models/Group.php b/models/Group.php new file mode 100644 index 000000000..3b6b67251 --- /dev/null +++ b/models/Group.php @@ -0,0 +1,13 @@ + Doctrine_Connection +// won't initialize grouptable when Doctrine_Connection->getTable('Group') is called + +class GroupTable { } +class Group extends Entity { + public function setUp() { + parent::setUp(); + $this->hasMany('User', 'Groupuser.user_id'); +// $this->option('inheritanceMap', array('type' => 1)); + } +} + diff --git a/models/GroupUser.php b/models/GroupUser.php new file mode 100644 index 000000000..ce5f8b7bd --- /dev/null +++ b/models/GroupUser.php @@ -0,0 +1,10 @@ +hasColumn('added', 'integer'); + $this->hasColumn('group_id', 'integer'); + $this->hasColumn('user_id', 'integer'); + } +} diff --git a/models/GzipTest.php b/models/GzipTest.php new file mode 100644 index 000000000..64dc9996d --- /dev/null +++ b/models/GzipTest.php @@ -0,0 +1,6 @@ +hasColumn('gzip', 'gzip', 100000); + } +} diff --git a/models/InheritanceTest.php b/models/InheritanceTest.php new file mode 100644 index 000000000..c19d21d94 --- /dev/null +++ b/models/InheritanceTest.php @@ -0,0 +1,19 @@ +hasColumn('name', 'string'); + $this->hasColumn('type', 'string'); + + $this->setSubclasses(array('InheritanceChildTest' => array('type' => 'type 1'), + 'InheritanceChild2Test' => array('type' => 'type 2'))); + } +} + +class InheritanceChildTest extends InheritanceTest +{ } + +class InheritanceChild2Test extends InheritanceTest +{ } + diff --git a/models/JC1.php b/models/JC1.php new file mode 100644 index 000000000..6c5183426 --- /dev/null +++ b/models/JC1.php @@ -0,0 +1,8 @@ +hasColumn('c1_id', 'integer'); + $this->hasColumn('c2_id', 'integer'); + } +} + diff --git a/models/JC2.php b/models/JC2.php new file mode 100644 index 000000000..7f6c27cc4 --- /dev/null +++ b/models/JC2.php @@ -0,0 +1,8 @@ +hasColumn('c1_id', 'integer'); + $this->hasColumn('c2_id', 'integer'); + } +} + diff --git a/models/JC3.php b/models/JC3.php new file mode 100644 index 000000000..a3d68cc5d --- /dev/null +++ b/models/JC3.php @@ -0,0 +1,8 @@ +hasColumn('c1_id', 'integer'); + $this->hasColumn('c2_id', 'integer'); + } +} + diff --git a/models/LiabilityCodeN.php b/models/LiabilityCodeN.php new file mode 100644 index 000000000..895c3f194 --- /dev/null +++ b/models/LiabilityCodeN.php @@ -0,0 +1,14 @@ +setTableName('liability_codes'); + $this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true)); + $this->hasColumn('code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,)); + $this->hasColumn('description', 'string', 4000, array ( 'notnull' => true, 'notblank' => true,)); + } + + public function setUp(){ +# $this->index('code', array('fields' => 'code')); + } +} diff --git a/models/LocationI18n.php b/models/LocationI18n.php new file mode 100644 index 000000000..5703b984f --- /dev/null +++ b/models/LocationI18n.php @@ -0,0 +1,15 @@ +hasColumn('name', 'string', 50, array()); + $this->hasColumn('id', 'integer', 10, array('primary' => true)); + $this->hasColumn('culture', 'string', 2); + } + + public function setUp() + { + $this->hasOne('Location as Location', array('local' => 'id')); + } +} diff --git a/models/Log_Entry.php b/models/Log_Entry.php new file mode 100644 index 000000000..8fe5778a8 --- /dev/null +++ b/models/Log_Entry.php @@ -0,0 +1,10 @@ +hasColumn('stamp', 'timestamp'); + $this->hasColumn('status_id', 'integer'); + } + public function setUp() { + $this->hasOne('Log_Status', 'Log_Entry.status_id'); + } +} diff --git a/models/Log_Status.php b/models/Log_Status.php new file mode 100644 index 000000000..e8540e858 --- /dev/null +++ b/models/Log_Status.php @@ -0,0 +1,6 @@ +hasColumn('name', 'string', 255); + } +} diff --git a/models/M2MTest.php b/models/M2MTest.php new file mode 100644 index 000000000..39c72b28b --- /dev/null +++ b/models/M2MTest.php @@ -0,0 +1,16 @@ +hasColumn('name', 'string', 200); + $this->hasColumn('child_id', 'integer'); + } + public function setUp() { + + $this->hasMany('RTC1 as RTC1', 'JC1.c1_id'); + $this->hasMany('RTC2 as RTC2', 'JC1.c1_id'); + $this->hasMany('RTC3 as RTC3', 'JC2.c1_id'); + $this->hasMany('RTC3 as RTC4', 'JC1.c1_id'); + + } +} + diff --git a/models/M2MTest2.php b/models/M2MTest2.php new file mode 100644 index 000000000..ce4cdf6c3 --- /dev/null +++ b/models/M2MTest2.php @@ -0,0 +1,11 @@ +hasColumn('oid', 'integer', 11, array('autoincrement', 'primary')); + $this->hasColumn('name', 'string', 20); + } + public function setUp() { + $this->hasMany('RTC4 as RTC5', 'JC3.c1_id'); + } +} + diff --git a/models/MyGroup.php b/models/MyGroup.php new file mode 100644 index 000000000..dfc6b76ff --- /dev/null +++ b/models/MyGroup.php @@ -0,0 +1,17 @@ +setTableName('my_group'); + + $this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,)); + $this->hasColumn('name', 'string', 255, array ( 'notnull' => true,)); + $this->hasColumn('description', 'string', 4000, array ()); + } + + public function setUp() + { + $this->hasMany('MyUser as users', array('refClass' => 'MyUserGroup', 'local' => 'group_id', 'foreign' => 'user_id')); + } +} diff --git a/models/MyOneThing.php b/models/MyOneThing.php new file mode 100644 index 000000000..8d328cb3c --- /dev/null +++ b/models/MyOneThing.php @@ -0,0 +1,10 @@ +hasColumn('name', 'string'); + $this->hasColumn('user_id', 'integer'); + } + public function setUp() { + $this->hasMany('MyUserOneThing', 'MyUserOneThing.one_thing_id'); + } +} diff --git a/models/MyOtherThing.php b/models/MyOtherThing.php new file mode 100644 index 000000000..8a43926c3 --- /dev/null +++ b/models/MyOtherThing.php @@ -0,0 +1,10 @@ +hasColumn('name', 'string'); + $this->hasColumn('user_id', 'integer'); + } + public function setUp() { + $this->hasMany('MyUserOtherThing', 'MyUserOtherThing.other_thing_id'); + } +} diff --git a/models/MyUser.php b/models/MyUser.php new file mode 100644 index 000000000..b9ff46de6 --- /dev/null +++ b/models/MyUser.php @@ -0,0 +1,10 @@ +hasColumn('name', 'string'); + } + public function setUp() { + $this->hasMany('MyOneThing', 'MyOneThing.user_id'); + $this->hasMany('MyOtherThing', 'MyOtherThing.user_id'); + } +} diff --git a/models/MyUser2.php b/models/MyUser2.php new file mode 100644 index 000000000..8e98a59eb --- /dev/null +++ b/models/MyUser2.php @@ -0,0 +1,23 @@ +setTableName('my_user'); + + $this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,)); + $this->hasColumn('username', 'string', 128, array ( 'notnull' => true,)); + $this->hasColumn('algorithm', 'string', 128, array ( 'default' => 'sha1', 'notnull' => true,)); + $this->hasColumn('salt', 'string', 128, array ( 'notnull' => true,)); + $this->hasColumn('password', 'string', 128, array ( 'notnull' => true,)); + $this->hasColumn('created_at', 'timestamp', null, array ()); + $this->hasColumn('last_login', 'timestamp', null, array ()); + $this->hasColumn('is_active', 'boolean', null, array ( 'default' => 1, 'notnull' => true,)); + $this->hasColumn('is_super_admin', 'boolean', null, array ( 'default' => 0, 'notnull' => true,)); + } + + public function setUp() + { + $this->hasMany('MyGroup as groups', array('refClass' => 'MyUserGroup', 'local' => 'user_id', 'foreign' => 'group_id')); + } +} diff --git a/models/MyUserGroup.php b/models/MyUserGroup.php new file mode 100644 index 000000000..8ff4e3f0b --- /dev/null +++ b/models/MyUserGroup.php @@ -0,0 +1,18 @@ +setTableName('my_user_group'); + + $this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,)); + $this->hasColumn('group_id', 'integer', 4, array ()); + $this->hasColumn('user_id', 'integer', 4, array ()); + } + + public function setUp() + { + $this->hasOne('MyGroup as MyGroup', 'MyUserGroup.group_id'); + $this->hasOne('MyUser as MyUser', 'MyUserGroup.user_id'); + } +} diff --git a/models/MyUserOneThing.php b/models/MyUserOneThing.php new file mode 100644 index 000000000..b681043d0 --- /dev/null +++ b/models/MyUserOneThing.php @@ -0,0 +1,7 @@ +hasColumn('user_id', 'integer'); + $this->hasColumn('one_thing_id', 'integer'); + } +} diff --git a/models/MyUserOtherThing.php b/models/MyUserOtherThing.php new file mode 100644 index 000000000..cbe702483 --- /dev/null +++ b/models/MyUserOtherThing.php @@ -0,0 +1,7 @@ +hasColumn('user_id', 'integer'); + $this->hasColumn('other_thing_id', 'integer'); + } +} diff --git a/models/MysqlGroup.php b/models/MysqlGroup.php new file mode 100644 index 000000000..cccae6325 --- /dev/null +++ b/models/MysqlGroup.php @@ -0,0 +1,10 @@ +hasColumn('name', 'string', null); + + $this->hasMany('MysqlUser', 'MysqlGroupMember.user_id'); + } +} diff --git a/models/MysqlGroupMember.php b/models/MysqlGroupMember.php new file mode 100644 index 000000000..3df5a3728 --- /dev/null +++ b/models/MysqlGroupMember.php @@ -0,0 +1,10 @@ +hasColumn('group_id', 'integer', null, 'primary'); + $this->hasColumn('user_id', 'integer', null, 'primary'); + } +} + diff --git a/models/MysqlTestRecord.php b/models/MysqlTestRecord.php new file mode 100644 index 000000000..44bd8f582 --- /dev/null +++ b/models/MysqlTestRecord.php @@ -0,0 +1,11 @@ +hasColumn('name', 'string', null, 'primary'); + $this->hasColumn('code', 'integer', null, 'primary'); + + $this->option('type', 'INNODB'); + } +} diff --git a/models/MysqlUser.php b/models/MysqlUser.php new file mode 100644 index 000000000..2b4981ce7 --- /dev/null +++ b/models/MysqlUser.php @@ -0,0 +1,10 @@ +hasColumn('name', 'string', null); + + $this->hasMany('MysqlGroup', 'MysqlGroupMember.group_id'); + } +} diff --git a/models/NestReference.php b/models/NestReference.php new file mode 100644 index 000000000..0f2d05888 --- /dev/null +++ b/models/NestReference.php @@ -0,0 +1,9 @@ +hasColumn('parent_id', 'integer', 4, 'primary'); + $this->hasColumn('child_id', 'integer', 4, 'primary'); + } +} diff --git a/models/NestTest.php b/models/NestTest.php new file mode 100644 index 000000000..f1bdea67a --- /dev/null +++ b/models/NestTest.php @@ -0,0 +1,22 @@ +hasColumn('name', 'string'); + } + public function setUp() + { + $this->hasMany('NestTest as Parents', array('local' => 'child_id', + 'refClass' => 'NestReference', + 'foreign' => 'parent_id')); + $this->hasMany('NestTest as Children', array('local' => 'parent_id', + 'refClass' => 'NestReference', + 'foreign' => 'child_id')); + + $this->hasMany('NestTest as Relatives', array('local' => 'child_id', + 'refClass' => 'NestReference', + 'foreign' => 'parent_id', + 'equal' => true)); + } +} diff --git a/models/NestedSetTest_SingleRootNode.php b/models/NestedSetTest_SingleRootNode.php new file mode 100644 index 000000000..1aea10b8f --- /dev/null +++ b/models/NestedSetTest_SingleRootNode.php @@ -0,0 +1,9 @@ +actAs('NestedSet'); + $this->hasColumn('name', 'string', 50, array('notnull')); + } + +} diff --git a/models/NotNullTest.php b/models/NotNullTest.php new file mode 100644 index 000000000..786d213a2 --- /dev/null +++ b/models/NotNullTest.php @@ -0,0 +1,7 @@ +hasColumn('name', 'string', 100, 'notnull'); + $this->hasColumn('type', 'integer', 11); + } +} diff --git a/models/ORM_AccessControl.php b/models/ORM_AccessControl.php new file mode 100644 index 000000000..f1cbb1bd3 --- /dev/null +++ b/models/ORM_AccessControl.php @@ -0,0 +1,12 @@ +hasColumn('name', 'string', 255); + } + public function setUp() + { + $this->hasMany('ORM_AccessGroup as accessGroups', 'ORM_AccessControlsGroups.accessGroupID'); + } +} diff --git a/models/ORM_AccessControlsGroups.php b/models/ORM_AccessControlsGroups.php new file mode 100644 index 000000000..218b219c3 --- /dev/null +++ b/models/ORM_AccessControlsGroups.php @@ -0,0 +1,9 @@ +hasColumn('accessControlID', 'integer', 11, array('primary' => true)); + $this->hasColumn('accessGroupID', 'integer', 11, array('primary' => true)); + } +} diff --git a/models/ORM_AccessGroup.php b/models/ORM_AccessGroup.php new file mode 100644 index 000000000..ac824259f --- /dev/null +++ b/models/ORM_AccessGroup.php @@ -0,0 +1,12 @@ +hasColumn('name', 'string', 255); + } + public function setUp() + { + $this->hasMany('ORM_AccessControl as accessControls', 'ORM_AccessControlsGroups.accessControlID'); + } +} diff --git a/models/ORM_TestEntry.php b/models/ORM_TestEntry.php new file mode 100644 index 000000000..4ca7e55a5 --- /dev/null +++ b/models/ORM_TestEntry.php @@ -0,0 +1,15 @@ +setTableName('test_entries'); + $this->hasColumn('id', 'integer', 11, 'autoincrement|primary'); + $this->hasColumn('name', 'string', 255); + $this->hasColumn('stamp', 'timestamp'); + $this->hasColumn('amount', 'float'); + $this->hasColumn('itemID', 'integer'); + } + + public function setUp() { + $this->hasOne('ORM_TestItem', 'ORM_TestEntry.itemID'); + } +} diff --git a/models/ORM_TestItem.php b/models/ORM_TestItem.php new file mode 100644 index 000000000..93b9c8bcd --- /dev/null +++ b/models/ORM_TestItem.php @@ -0,0 +1,13 @@ +setTableName('test_items'); + $this->hasColumn('id', 'integer', 11, 'autoincrement|primary'); + $this->hasColumn('name', 'string', 255); + } + + public function setUp() { + + $this->hasOne('ORM_TestEntry', 'ORM_TestEntry.itemID'); + } +} diff --git a/models/Package.php b/models/Package.php new file mode 100644 index 000000000..2554dc2e2 --- /dev/null +++ b/models/Package.php @@ -0,0 +1,11 @@ +hasColumn('description', 'string', 255); + } + + public function setUp() + { + $this->ownsMany('PackageVersion as Version', 'PackageVersion.package_id'); + } +} diff --git a/models/PackageVersion.php b/models/PackageVersion.php new file mode 100644 index 000000000..45aaf90ae --- /dev/null +++ b/models/PackageVersion.php @@ -0,0 +1,12 @@ +hasColumn('package_id', 'integer'); + $this->hasColumn('description', 'string', 255); + } + public function setUp() + { + $this->hasOne('Package', 'PackageVersion.package_id'); + $this->hasMany('PackageVersionNotes as Note', 'PackageVersionNotes.package_version_id'); + } +} diff --git a/models/PackageVersionNotes.php b/models/PackageVersionNotes.php new file mode 100644 index 000000000..6e880def9 --- /dev/null +++ b/models/PackageVersionNotes.php @@ -0,0 +1,13 @@ +hasColumn('package_version_id', 'integer'); + $this->hasColumn('description', 'string', 255); + } + public function setUp() + { + $this->hasOne('PackageVersion', 'PackageVersionNotes.package_version_id'); + } +} diff --git a/models/Phonenumber.php b/models/Phonenumber.php new file mode 100644 index 000000000..63d27a5a9 --- /dev/null +++ b/models/Phonenumber.php @@ -0,0 +1,15 @@ +hasColumn('phonenumber', 'string',20); + $this->hasColumn('entity_id', 'integer'); + } + public function setUp() + { + $this->hasOne('Entity', array('local' => 'entity_id', + 'foreign' => 'id', + 'onDelete' => 'CASCADE')); + } +} diff --git a/models/Photo.php b/models/Photo.php new file mode 100644 index 000000000..62fd4c972 --- /dev/null +++ b/models/Photo.php @@ -0,0 +1,9 @@ +hasMany('Tag', 'Phototag.tag_id'); + } + public function setTableDefinition() { + $this->hasColumn('name', 'string', 100); + } +} diff --git a/models/Phototag.php b/models/Phototag.php new file mode 100644 index 000000000..cb1aaab14 --- /dev/null +++ b/models/Phototag.php @@ -0,0 +1,7 @@ +hasColumn('photo_id', 'integer'); + $this->hasColumn('tag_id', 'integer'); + } +} diff --git a/models/Policy.php b/models/Policy.php new file mode 100644 index 000000000..37385d8b0 --- /dev/null +++ b/models/Policy.php @@ -0,0 +1,15 @@ +hasColumn('policy_number', 'integer', 11, array('unique' => true)); + } + + public function setUp() + { + $this->hasMany('PolicyAsset as PolicyAssets', array('local' => 'policy_number', + 'foreign' => 'policy_number')); + $this->index('policy_number_index', array('fields' => array('policy_number'))); + } +} diff --git a/models/PolicyAsset.php b/models/PolicyAsset.php new file mode 100644 index 000000000..f68da7a02 --- /dev/null +++ b/models/PolicyAsset.php @@ -0,0 +1,16 @@ +hasColumn('policy_number', 'integer', 11); + $this->hasColumn('value', 'float', 10, array ('notblank' => true,)); + } + + public function setUp() + { + $this->hasOne('Policy', array('foreign' => 'policy_number', + 'local' => 'policy_number')); + $this->index('policy_number_index', array('fields' => array('policy_number'))); + } +} diff --git a/models/PolicyCodeN.php b/models/PolicyCodeN.php new file mode 100644 index 000000000..1d3df65fa --- /dev/null +++ b/models/PolicyCodeN.php @@ -0,0 +1,14 @@ +setTableName('policy_codes'); + $this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true)); + $this->hasColumn('code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,)); + $this->hasColumn('description', 'string', 4000, array ( 'notnull' => true, 'notblank' => true,)); + } + + public function setUp(){ +# $this->index('code', array('fields' => 'code')); + } +} diff --git a/models/PolicyN.php b/models/PolicyN.php new file mode 100644 index 000000000..dc8cf95b2 --- /dev/null +++ b/models/PolicyN.php @@ -0,0 +1,15 @@ +setTableName('policies'); + $this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true)); + $this->hasColumn('rate_id', 'integer', 4, array ( )); + $this->hasColumn('policy_number', 'integer', 4, array ( 'unique' => true, )); + } + + public function setUp(){ + $this->hasOne('RateN', array('local' => 'rate_id', 'foreign' => 'id' )); + } + +} diff --git a/models/QueryTest_Board.php b/models/QueryTest_Board.php new file mode 100644 index 000000000..e326c9830 --- /dev/null +++ b/models/QueryTest_Board.php @@ -0,0 +1,27 @@ +hasColumn('categoryId as categoryId', 'integer', 4, + array('notnull')); + $this->hasColumn('name as name', 'string', 100, + array('notnull', 'unique')); + $this->hasColumn('lastEntryId as lastEntryId', 'integer', 4, + array('default' => 0, 'notnull')); + $this->hasColumn('position as position', 'integer', 4, + array('default' => 0, 'notnull')); + } + + /** + * Initializes the relations. + */ + public function setUp() + { + $this->hasOne('QueryTest_Category as category', 'QueryTest_Board.categoryId'); + $this->ownsOne('QueryTest_Entry as lastEntry', 'QueryTest_Board.lastEntryId'); + } +} diff --git a/models/QueryTest_Category.php b/models/QueryTest_Category.php new file mode 100644 index 000000000..3c2887b8e --- /dev/null +++ b/models/QueryTest_Category.php @@ -0,0 +1,36 @@ +hasColumn('rootCategoryId as rootCategoryId', 'integer', 4, + array('default' => 0)); + $this->hasColumn('parentCategoryId as parentCategoryId', 'integer', 4, + array('notnull', 'default' => 0)); + $this->hasColumn('name as name', 'string', 50, + array('notnull', 'unique')); + $this->hasColumn('position as position', 'integer', 4, + array('default' => 0, 'notnull')); + } + + /** + * Relations definition. + */ + public function setUp() + { + $this->ownsMany('QueryTest_Category as subCategories', 'subCategories.parentCategoryId'); + $this->hasOne('QueryTest_Category as rootCategory', 'QueryTest_Category.rootCategoryId'); + $this->ownsMany('QueryTest_Board as boards', 'QueryTest_Board.categoryId'); + } +} diff --git a/models/QueryTest_Entry.php b/models/QueryTest_Entry.php new file mode 100644 index 000000000..24e9fde89 --- /dev/null +++ b/models/QueryTest_Entry.php @@ -0,0 +1,22 @@ +hasColumn('authorId', 'integer', 4, + array('notnull')); + $this->hasColumn('date', 'integer', 4, + array('notnull')); + } + + /** + * Runtime definition of the relationships to other entities. + */ + public function setUp() + { + $this->hasOne('QueryTest_User as author', 'QueryTest_Entry.authorId'); + } +} diff --git a/models/QueryTest_Item.php b/models/QueryTest_Item.php new file mode 100644 index 000000000..797f4c04f --- /dev/null +++ b/models/QueryTest_Item.php @@ -0,0 +1,10 @@ +hasColumn('price', 'decimal'); + $this->hasColumn('quantity', 'integer'); + } +} + diff --git a/models/QueryTest_Rank.php b/models/QueryTest_Rank.php new file mode 100644 index 000000000..bbe24328d --- /dev/null +++ b/models/QueryTest_Rank.php @@ -0,0 +1,20 @@ +hasColumn('title as title', 'string', 100, + array('notnull')); + $this->hasColumn('color as color', 'string', 20, + array('notnull', 'regexp' => '/^[a-zA-Z\-]{3,}|#[0-9a-fA-F]{6}$/D')); + $this->hasColumn('icon as icon', 'string', 50, + array('notnull', 'default' => ' ', 'regexp' => '/^[a-zA-Z0-9_\-]+\.(jpg|gif|png)$/D')); + } + public function setUp() + { + $this->hasMany('QueryTest_User as users', 'QueryTest_UserRank.userId'); + } +} diff --git a/models/QueryTest_User.php b/models/QueryTest_User.php new file mode 100644 index 000000000..1d3c5e85b --- /dev/null +++ b/models/QueryTest_User.php @@ -0,0 +1,20 @@ +hasColumn('username as username', 'string', 50, + array('notnull')); + $this->hasColumn('visibleRankId', 'integer', 4); + } + + /** + * Runtime definition of the relationships to other entities. + */ + public function setUp() + { + $this->hasOne('QueryTest_Rank as visibleRank', 'QueryTest_User.visibleRankId'); + $this->hasMany('QueryTest_Rank as ranks', 'QueryTest_UserRank.rankId'); + } +} diff --git a/models/QueryTest_UserRank.php b/models/QueryTest_UserRank.php new file mode 100644 index 000000000..9f9d75b7e --- /dev/null +++ b/models/QueryTest_UserRank.php @@ -0,0 +1,9 @@ +hasColumn('rankId', 'integer', 4, array('primary')); + $this->hasColumn('userId', 'integer', 4, array('primary')); + } +} diff --git a/models/RTC1.php b/models/RTC1.php new file mode 100644 index 000000000..7cb4ca037 --- /dev/null +++ b/models/RTC1.php @@ -0,0 +1,10 @@ +hasColumn('name', 'string', 200); + } + public function setUp() { + $this->hasMany('M2MTest as RTC1', 'JC1.c2_id'); + } +} + diff --git a/models/RTC2.php b/models/RTC2.php new file mode 100644 index 000000000..d66d21518 --- /dev/null +++ b/models/RTC2.php @@ -0,0 +1,10 @@ +hasColumn('name', 'string', 200); + } + public function setUp() { + $this->hasMany('M2MTest as RTC2', 'JC1.c2_id'); + } +} + diff --git a/models/RTC3.php b/models/RTC3.php new file mode 100644 index 000000000..e93b43e28 --- /dev/null +++ b/models/RTC3.php @@ -0,0 +1,11 @@ +hasColumn('name', 'string', 200); + } + public function setUp() { + $this->hasMany('M2MTest as RTC3', 'JC2.c2_id'); + $this->hasMany('M2MTest as RTC4', 'JC1.c2_id'); + } +} + diff --git a/models/RTC4.php b/models/RTC4.php new file mode 100644 index 000000000..12461b851 --- /dev/null +++ b/models/RTC4.php @@ -0,0 +1,10 @@ +hasColumn('oid', 'integer', 11, array('autoincrement', 'primary')); + $this->hasColumn('name', 'string', 20); + } + public function setUp() { + $this->hasMany('M2MTest2', 'JC3.c2_id'); + } +} diff --git a/models/RateN.php b/models/RateN.php new file mode 100644 index 000000000..f2adbb48d --- /dev/null +++ b/models/RateN.php @@ -0,0 +1,22 @@ +setTableName('rates'); + $this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true)); + $this->hasColumn('policy_code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,)); + $this->hasColumn('coverage_code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,)); + $this->hasColumn('liability_code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,)); + $this->hasColumn('total_rate', 'float', null, array ( 'notnull' => true, 'notblank' => true,)); + } + + public function setUp(){ +# $this->index('policy_code_idx', array('fields' => 'policy_code')); +# $this->index('coverage_code_idx', array('fields' => 'coverage_code')); +# $this->index('liability_code_idx', array('fields' => 'liability_code')); + $this->hasOne('PolicyCodeN', array('local' => 'policy_code', 'foreign' => 'code' )); + $this->hasOne('CoverageCodeN', array('local' => 'coverage_code', 'foreign' => 'code' )); + $this->hasOne('LiabilityCodeN', array('local' => 'liability_code', 'foreign' => 'code' )); + } + +} diff --git a/models/Rec1.php b/models/Rec1.php new file mode 100644 index 000000000..32ef64f25 --- /dev/null +++ b/models/Rec1.php @@ -0,0 +1,15 @@ +hasColumn('first_name', 'string', 128, array ()); + } + + public function setUp() + { + $this->ownsOne('Rec2 as Account', array('local' => 'id', 'foreign' => 'user_id')); + } +} + + diff --git a/models/Rec2.php b/models/Rec2.php new file mode 100644 index 000000000..45a35c517 --- /dev/null +++ b/models/Rec2.php @@ -0,0 +1,15 @@ +hasColumn('user_id', 'integer', 10, array ( 'unique' => true,)); + $this->hasColumn('address', 'string', 150, array ()); + } + + public function setUp() + { + $this->ownsOne('Rec1 as User', 'Rec2.user_id'); + } + +} diff --git a/models/RecordFilterTest.php b/models/RecordFilterTest.php new file mode 100644 index 000000000..cea5d0f9b --- /dev/null +++ b/models/RecordFilterTest.php @@ -0,0 +1,16 @@ +setAttribute(Doctrine::ATTR_ACCESSORS, Doctrine::ACCESSOR_BOTH); + + $this->hasColumn("name", "string", 200); + $this->hasColumn("password", "string", 32); + } + public function setPassword($password) { + return md5($password); + } + public function getName($name) { + return strtoupper($name); + } +} diff --git a/models/RecordHookTest.php b/models/RecordHookTest.php new file mode 100644 index 000000000..b725cb1a4 --- /dev/null +++ b/models/RecordHookTest.php @@ -0,0 +1,46 @@ +hasColumn('name', 'string', null, array('primary' => true)); + } + public function preSave($event) + { + $this->_messages[] = __FUNCTION__; + } + public function postSave($event) + { + $this->_messages[] = __FUNCTION__; + } + public function preInsert($event) + { + $this->_messages[] = __FUNCTION__; + } + public function postInsert($event) + { + $this->_messages[] = __FUNCTION__; + } + public function preUpdate($event) + { + $this->_messages[] = __FUNCTION__; + } + public function postUpdate($event) + { + $this->_messages[] = __FUNCTION__; + } + public function preDelete($event) + { + $this->_messages[] = __FUNCTION__; + } + public function postDelete($event) + { + $this->_messages[] = __FUNCTION__; + } + public function pop() + { + return array_pop($this->_messages); + } +} diff --git a/models/location.php b/models/Record_City.php similarity index 51% rename from models/location.php rename to models/Record_City.php index 0e21dfe97..3259fb9b4 100644 --- a/models/location.php +++ b/models/Record_City.php @@ -1,25 +1,12 @@ -hasColumn('name', 'string', 200); - } - public function setUp() { - $this->hasMany('Record_City as City', 'City.country_id'); - } -} -class Record_City extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string', 200); - $this->hasColumn('country_id', 'integer'); - $this->hasColumn('district_id', 'integer'); - } - public function setUp() { - $this->hasOne('Record_Country as Country', 'Record_City.country_id'); - $this->hasOne('Record_District as District', 'Record_City.district_id'); - } -} -class Record_District extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string', 200); - } -} +hasColumn('name', 'string', 200); + $this->hasColumn('country_id', 'integer'); + $this->hasColumn('district_id', 'integer'); + } + public function setUp() { + $this->hasOne('Record_Country as Country', 'Record_City.country_id'); + $this->hasOne('Record_District as District', 'Record_City.district_id'); + } +} diff --git a/models/Record_Country.php b/models/Record_Country.php new file mode 100644 index 000000000..c6f873bea --- /dev/null +++ b/models/Record_Country.php @@ -0,0 +1,11 @@ +hasColumn('name', 'string', 200); + } + public function setUp() { + $this->hasMany('Record_City as City', 'City.country_id'); + } +} + + diff --git a/models/Record_District.php b/models/Record_District.php new file mode 100644 index 000000000..a56ccf8b3 --- /dev/null +++ b/models/Record_District.php @@ -0,0 +1,6 @@ +hasColumn('name', 'string', 200); + } +} diff --git a/models/RelationTest.php b/models/RelationTest.php new file mode 100644 index 000000000..b6972e997 --- /dev/null +++ b/models/RelationTest.php @@ -0,0 +1,10 @@ +hasColumn('name', 'string', 200); + $this->hasColumn('child_id', 'integer'); + } +} + diff --git a/models/RelationTestChild.php b/models/RelationTestChild.php new file mode 100644 index 000000000..befdc35c3 --- /dev/null +++ b/models/RelationTestChild.php @@ -0,0 +1,10 @@ +hasOne('RelationTest as Parent', 'RelationTestChild.child_id'); + + $this->ownsMany('RelationTestChild as Children', 'RelationTestChild.child_id'); + } +} diff --git a/models/ResourceReference.php b/models/ResourceReference.php new file mode 100644 index 000000000..aec7795b2 --- /dev/null +++ b/models/ResourceReference.php @@ -0,0 +1,8 @@ +hasColumn('type_id', 'integer'); + $this->hasColumn('resource_id', 'integer'); + } +} + diff --git a/models/ResourceTask.php b/models/ResourceTask.php new file mode 100644 index 000000000..cb91c5e41 --- /dev/null +++ b/models/ResourceTask.php @@ -0,0 +1,10 @@ +hasMany('Task as TaskAlias', 'Assignment.task_id'); + $this->hasMany('ResourceType as Type', 'ResourceReference.type_id'); + } + public function setTableDefinition() { + $this->hasColumn('name', 'string',100); + } +} diff --git a/models/ResourceType.php b/models/ResourceType.php new file mode 100644 index 000000000..9dfb9c2b2 --- /dev/null +++ b/models/ResourceType.php @@ -0,0 +1,10 @@ +hasMany('Resource as ResourceAlias', 'ResourceReference.resource_id'); + } + public function setTableDefinition() { + $this->hasColumn('type', 'string',100); + } +} + diff --git a/models/Role.php b/models/Role.php new file mode 100644 index 000000000..44e46e9a6 --- /dev/null +++ b/models/Role.php @@ -0,0 +1,13 @@ +hasColumn('name', 'string', 20, array('unique' => true)); + } + public function setUp() + { + $this->hasMany('Auth', array('local' => 'id', 'foreign' => 'roleid')); + } +} + diff --git a/models/SelfRefTest.php b/models/SelfRefTest.php new file mode 100644 index 000000000..fdf9dd3e1 --- /dev/null +++ b/models/SelfRefTest.php @@ -0,0 +1,14 @@ +hasColumn('name', 'string', 50); + $this->hasColumn('created_by', 'integer'); + } + public function setUp() + { + $this->hasOne('SelfRefTest as createdBy', array('local' => 'created_by')); + } +} + diff --git a/models/SequenceRecord.php b/models/SequenceRecord.php new file mode 100644 index 000000000..673f133bb --- /dev/null +++ b/models/SequenceRecord.php @@ -0,0 +1,8 @@ +hasColumn('id', 'integer', null, array('primary', 'sequence')); + $this->hasColumn('name', 'string'); + } +} diff --git a/models/SerializeTest.php b/models/SerializeTest.php new file mode 100644 index 000000000..cc16ec4c1 --- /dev/null +++ b/models/SerializeTest.php @@ -0,0 +1,31 @@ +setTableName('serialize_test'); + + $this->hasColumn('booltest', 'boolean'); + $this->hasColumn('integertest', 'integer', 4, array('unsigned' => true)); + $this->hasColumn('floattest', 'float'); + $this->hasColumn('stringtest', 'string', 200, array('fixed' => true)); + $this->hasColumn('arraytest', 'array', 10000); + $this->hasColumn('objecttest', 'object'); + $this->hasColumn('blobtest', 'blob'); + $this->hasColumn('clobtest', 'clob'); + $this->hasColumn('timestamptest', 'timestamp'); + $this->hasColumn('timetest', 'time'); + $this->hasColumn('datetest', 'date'); + $this->hasColumn('enumtest', 'enum', 4, + array( + 'values' => array( + 'php', + 'java', + 'python' + ) + ) + ); + $this->hasColumn('gziptest', 'gzip'); + } + +} diff --git a/models/SoftDeleteTest.php b/models/SoftDeleteTest.php new file mode 100644 index 000000000..ed7aba62a --- /dev/null +++ b/models/SoftDeleteTest.php @@ -0,0 +1,20 @@ +hasColumn('name', 'string', null, array('primary' => true)); + $this->hasColumn('something', 'string', '25', array('notnull' => true, 'unique' => true)); + $this->hasColumn('deleted', 'boolean', 1); + } + public function preDelete($event) + { + $event->skipOperation(); + } + public function postDelete($event) + { + $this->deleted = true; + + $this->save(); + } +} diff --git a/models/Song.php b/models/Song.php new file mode 100644 index 000000000..0bdf57e76 --- /dev/null +++ b/models/Song.php @@ -0,0 +1,8 @@ +hasColumn('album_id', 'integer'); + $this->hasColumn('genre', 'string',20); + $this->hasColumn('title', 'string',30); + } +} diff --git a/models/Tag.php b/models/Tag.php new file mode 100644 index 000000000..2563172e2 --- /dev/null +++ b/models/Tag.php @@ -0,0 +1,9 @@ +hasMany('Photo', 'Phototag.photo_id'); + } + public function setTableDefinition() { + $this->hasColumn('tag', 'string', 100); + } +} diff --git a/models/Task.php b/models/Task.php new file mode 100644 index 000000000..9f5c3de90 --- /dev/null +++ b/models/Task.php @@ -0,0 +1,11 @@ +hasMany('Resource as ResourceAlias', 'Assignment.resource_id'); + $this->hasMany('Task as Subtask', 'Subtask.parent_id'); + } + public function setTableDefinition() { + $this->hasColumn('name', 'string',100); + $this->hasColumn('parent_id', 'integer'); + } +} diff --git a/models/TestMovie.php b/models/TestMovie.php new file mode 100644 index 000000000..482c6c542 --- /dev/null +++ b/models/TestMovie.php @@ -0,0 +1,27 @@ +hasOne('TestUser as User', + array('local' => 'user_id', + 'foreign' => 'id')); + + $this->hasMany('TestUser as MovieBookmarks', + array('local' => 'movie_id', + 'foreign' => 'user_id', + 'refClass' => 'TestMovieUserBookmark')); + + $this->hasMany('TestUser as MovieVotes', + array('local' => 'movie_id', + 'foreign' => 'user_id', + 'refClass' => 'TestMovieUserVote')); + } + + public function setTableDefinition() + { + $this->hasColumn('user_id', 'integer', null); + $this->hasColumn('name', 'string', 30); + } +} diff --git a/models/TestMovieUserBookmark.php b/models/TestMovieUserBookmark.php new file mode 100644 index 000000000..3d84a036b --- /dev/null +++ b/models/TestMovieUserBookmark.php @@ -0,0 +1,10 @@ +hasColumn('user_id', 'integer', null, array('primary' => true)); + $this->hasColumn('movie_id', 'integer', null, array('primary' => true)); + } +} + diff --git a/models/TestMovieUserVote.php b/models/TestMovieUserVote.php new file mode 100644 index 000000000..244f1f54a --- /dev/null +++ b/models/TestMovieUserVote.php @@ -0,0 +1,9 @@ +hasColumn('vote', 'string', 30); + $this->hasColumn('user_id', 'integer', null, array('primary' => true)); + $this->hasColumn('movie_id', 'integer', null, array('primary' => true)); + } +} diff --git a/models/TestRecord.php b/models/TestRecord.php new file mode 100644 index 000000000..9e1e445e5 --- /dev/null +++ b/models/TestRecord.php @@ -0,0 +1,8 @@ +setTableName('test'); + } +} diff --git a/models/TestUser.php b/models/TestUser.php new file mode 100644 index 000000000..f2e2e6cc6 --- /dev/null +++ b/models/TestUser.php @@ -0,0 +1,21 @@ +hasMany('TestMovie as UserBookmarks', + array('local' => 'user_id', + 'foreign' => 'movie_id', + 'refClass' => 'TestMovieUserBookmark')); + + $this->hasMany('TestMovie as UserVotes', + array('local' => 'user_id', + 'foreign' => 'movie_id', + 'refClass' => 'TestMovieUserVote')); + + } + public function setTableDefinition() + { + $this->hasColumn('name', 'string', 30); + } +} diff --git a/models/TreeLeaf.php b/models/TreeLeaf.php new file mode 100644 index 000000000..1cfe47a5e --- /dev/null +++ b/models/TreeLeaf.php @@ -0,0 +1,14 @@ +hasColumn('name', 'string'); + $this->hasColumn('parent_id', 'integer'); + } + public function setUp() + { + $this->hasOne('TreeLeaf as Parent', 'TreeLeaf.parent_id'); + $this->hasMany('TreeLeaf as Children', 'TreeLeaf.parent_id'); + } +} diff --git a/models/User.php b/models/User.php new file mode 100644 index 000000000..00f4855dd --- /dev/null +++ b/models/User.php @@ -0,0 +1,37 @@ +hasMany('Address', array('local' => 'user_id', + 'foreign' => 'address_id', + 'refClass' => 'EntityAddress')); + $this->ownsMany('Album', 'Album.user_id'); + $this->ownsMany('Book', 'Book.user_id'); + $this->hasMany('Group', 'Groupuser.group_id'); +// $this->option('inheritanceMap', array('type' => 0)); + } + /** Custom validation */ + public function validate() + { + // Allow only one name! + if ($this->name !== 'The Saint') { + $this->errorStack()->add('name', 'notTheSaint'); + } + } + public function validateOnInsert() + { + if ($this->password !== 'Top Secret') { + $this->errorStack()->add('password', 'pwNotTopSecret'); + } + } + public function validateOnUpdate() + { + if ($this->loginname !== 'Nobody') { + $this->errorStack()->add('loginname', 'notNobody'); + } + } +} + diff --git a/models/ValidatorTest.php b/models/ValidatorTest.php new file mode 100644 index 000000000..48aefb947 --- /dev/null +++ b/models/ValidatorTest.php @@ -0,0 +1,15 @@ +hasColumn('mymixed', 'string', 100); + $this->hasColumn('mystring', 'string', 100, 'notnull|unique'); + $this->hasColumn('myarray', 'array', 1000); + $this->hasColumn('myobject', 'object', 1000); + $this->hasColumn('myinteger', 'integer', 11); + $this->hasColumn('myrange', 'integer', 11, array('range' => array(4,123))); + $this->hasColumn('myregexp', 'string', 5, array('regexp' => '/^[0-9]+$/')); + + $this->hasColumn('myemail', 'string', 100, 'email'); + $this->hasColumn('myemail2', 'string', 100, 'email|notblank'); + } +} diff --git a/models/ValidatorTest_AddressModel.php b/models/ValidatorTest_AddressModel.php new file mode 100644 index 000000000..bbaab3147 --- /dev/null +++ b/models/ValidatorTest_AddressModel.php @@ -0,0 +1,18 @@ +hasColumn("id", "integer", 11, array('autoincrement' => true, + 'primary' => true + )); + $this->hasColumn('address1', 'string', 255, array('notnull' => true, 'notblank')); + $this->hasColumn('address2', 'string', 255, array('notnull' => true)); + $this->hasColumn('city', 'string', 255, array('notnull' => true, 'notblank')); + $this->hasColumn('state', 'string', 10, array('notnull' => true, 'notblank', 'usstate')); + $this->hasColumn('zip', 'string', 15, array('notnull' => true, 'notblank', 'regexp' => '/^[0-9-]*$/')); + } + + public function setUp() { + $this->hasMany('ValidatorTest_ClientModel', array('local' => 'address_id', 'foreign' => 'client_id', 'refClass' => 'ValidatorTest_ClientToAddressModel')); + } +} diff --git a/models/ValidatorTest_ClientModel.php b/models/ValidatorTest_ClientModel.php new file mode 100644 index 000000000..e0e12d716 --- /dev/null +++ b/models/ValidatorTest_ClientModel.php @@ -0,0 +1,15 @@ +hasColumn('id', 'integer', 4, array('notnull' => true, + 'primary' => true, + 'autoincrement' => true, + 'unsigned' => true)); + $this->hasColumn('short_name', 'string', 32, array('notnull' => true, 'notblank', 'unique' => true)); + } + + public function setUp() { + $this->hasMany("ValidatorTest_AddressModel", array('local' => 'client_id', 'foreign' => 'address_id', 'refClass' => 'ValidatorTest_ClientToAddressModel')); + } +} diff --git a/models/ValidatorTest_ClientToAddressModel.php b/models/ValidatorTest_ClientToAddressModel.php new file mode 100644 index 000000000..50375d4a9 --- /dev/null +++ b/models/ValidatorTest_ClientToAddressModel.php @@ -0,0 +1,15 @@ +hasColumn("client_id", "integer", 11, array('primary' => true)); + $this->hasColumn("address_id", "integer", 11, array('primary' => true)); + } + + public function construct(){ + } + + public function setUp() { + } +} diff --git a/models/ValidatorTest_FootballPlayer.php b/models/ValidatorTest_FootballPlayer.php new file mode 100644 index 000000000..e5a1693d7 --- /dev/null +++ b/models/ValidatorTest_FootballPlayer.php @@ -0,0 +1,8 @@ +hasColumn('person_id', 'string', 255); + $this->hasColumn('team_name', 'string', 255); + $this->hasColumn('goals_count', 'integer', 4); + } +} diff --git a/models/ValidatorTest_Person.php b/models/ValidatorTest_Person.php new file mode 100644 index 000000000..b4b191af3 --- /dev/null +++ b/models/ValidatorTest_Person.php @@ -0,0 +1,11 @@ +hasColumn('identifier', 'integer', 4, array('notblank', 'unique')); + $this->hasColumn('is_football_player', 'boolean'); + } + + public function setUp() { + $this->ownsOne('ValidatorTest_FootballPlayer', 'ValidatorTest_FootballPlayer.person_id'); + } +} diff --git a/models/VersioningTest.php b/models/VersioningTest.php new file mode 100644 index 000000000..7cb60d492 --- /dev/null +++ b/models/VersioningTest.php @@ -0,0 +1,13 @@ +hasColumn('name', 'string'); + $this->hasColumn('version', 'integer'); + } + public function setUp() + { + $this->actAs('Versionable'); + } +} diff --git a/models/ZeroValueTest.php b/models/ZeroValueTest.php new file mode 100644 index 000000000..5976148e7 --- /dev/null +++ b/models/ZeroValueTest.php @@ -0,0 +1,19 @@ +hasColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => true,)); + $this->hasColumn('username', 'string', 128, array('notnull' => true,)); + $this->hasColumn('algorithm', 'string', 128, array('default' => 'sha1', 'notnull' => true,)); + $this->hasColumn('salt', 'string', 128, array('notnull' => true,)); + $this->hasColumn('password', 'string', 128, array('notnull' => true,)); + $this->hasColumn('created_at', 'timestamp', null, array()); + $this->hasColumn('last_login', 'timestamp', null, array()); + $this->hasColumn('is_active', 'boolean', null, array('default' => true, 'notnull' => true,)); + $this->hasColumn('is_super_admin', 'boolean', null, array('default' => false, 'notnull' => true,)); + } + + public function setUp() + { } +} diff --git a/models/mmrGroupUser_B.php b/models/mmrGroupUser_B.php new file mode 100644 index 000000000..8d246383b --- /dev/null +++ b/models/mmrGroupUser_B.php @@ -0,0 +1,9 @@ +hasColumn('user_id', 'string', 30, array('primary' => true)); + $this->hasColumn('group_id', 'string', 30, array('primary' => true)); + } +} diff --git a/models/mmrGroupUser_C.php b/models/mmrGroupUser_C.php new file mode 100644 index 000000000..656e44df1 --- /dev/null +++ b/models/mmrGroupUser_C.php @@ -0,0 +1,10 @@ +hasColumn('user_id', 'string', 30, array('primary' => true)); + $this->hasColumn('group_id', 'string', 30, array('primary' => true)); + } +} diff --git a/models/mmrGroup_B.php b/models/mmrGroup_B.php new file mode 100644 index 000000000..f45eb8aa7 --- /dev/null +++ b/models/mmrGroup_B.php @@ -0,0 +1,14 @@ +hasMany('mmrUser_B', array('local' => 'group_id', + 'foreign' => 'user_id', + 'refClass' => 'mmrGroupUser_B')); + } + public function setTableDefinition() { + // Works when + $this->hasColumn('id', 'string', 30, array ( 'primary' => true)); + $this->hasColumn('name', 'string', 30); + } +} diff --git a/models/mmrGroup_C.php b/models/mmrGroup_C.php new file mode 100644 index 000000000..6b8f865ff --- /dev/null +++ b/models/mmrGroup_C.php @@ -0,0 +1,15 @@ +hasMany('mmrUser_C', array('local' => 'group_id', + 'foreign' => 'user_id', + 'refClass' => 'mmrGroupUser_C')); + } + public function setTableDefinition() + { + $this->hasColumn('g_id as id', 'string', 30, array('primary' => true)); + $this->hasColumn('name', 'string', 30); + } +} diff --git a/models/mmrUser_B.php b/models/mmrUser_B.php new file mode 100644 index 000000000..dcdca013e --- /dev/null +++ b/models/mmrUser_B.php @@ -0,0 +1,18 @@ +hasMany('mmrGroup_B as Group', array('local' => 'user_id', + 'foreign' => 'group_id', + 'refClass' => 'mmrGroupUser_B')); + + } + + public function setTableDefinition() + { + // Works when + $this->hasColumn('id', 'string', 30, array ( 'primary' => true)); + $this->hasColumn('name', 'string', 30); + } +} diff --git a/tests/AuditLogTestCase.php b/tests/AuditLogTestCase.php index 5fe5ead2f..866b14755 100644 --- a/tests/AuditLogTestCase.php +++ b/tests/AuditLogTestCase.php @@ -79,15 +79,3 @@ class Doctrine_AuditLog_TestCase extends Doctrine_UnitTestCase } } } -class VersioningTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string'); - $this->hasColumn('version', 'integer'); - } - public function setUp() - { - $this->actAs('Versionable'); - } -} diff --git a/tests/ColumnAggregationInheritanceTestCase.php b/tests/ColumnAggregationInheritanceTestCase.php index 4fc5f9c92..a794291ab 100644 --- a/tests/ColumnAggregationInheritanceTestCase.php +++ b/tests/ColumnAggregationInheritanceTestCase.php @@ -80,18 +80,3 @@ class Doctrine_ColumnAggregationInheritance_TestCase extends Doctrine_UnitTestCa $this->assertEqual('type 1', $child->type); } } -class InheritanceTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string'); - $this->hasColumn('type', 'string'); - - $this->setSubclasses(array('InheritanceChildTest' => array('type' => 'type 1'), - 'InheritanceChild2Test' => array('type' => 'type 2'))); - } -} -class InheritanceChildTest extends InheritanceTest -{ } -class InheritanceChild2Test extends InheritanceTest -{ } diff --git a/tests/ColumnAliasTestCase.php b/tests/ColumnAliasTestCase.php index 55e42a10f..537fb50b7 100644 --- a/tests/ColumnAliasTestCase.php +++ b/tests/ColumnAliasTestCase.php @@ -104,14 +104,4 @@ class Doctrine_ColumnAlias_TestCase extends Doctrine_UnitTestCase $this->assertEqual($coll[0]->alias1, 'someone'); } } -class ColumnAliasTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('column1 as alias1', 'string', 200); - $this->hasColumn('column2 as alias2', 'integer', 11); - } - public function setUp() - { - } -} + diff --git a/tests/EventListener/ChainTestCase.php b/tests/EventListener/ChainTestCase.php index bb17ec09e..fa9d28163 100644 --- a/tests/EventListener/ChainTestCase.php +++ b/tests/EventListener/ChainTestCase.php @@ -47,24 +47,4 @@ class Doctrine_EventListener_Chain_TestCase extends Doctrine_UnitTestCase } } -class EventListenerChainTest extends Doctrine_Record -{ - public function setTableDefinition() { - $this->hasColumn('name', 'string', 100); - } - public function setUp() { - $chain = new Doctrine_EventListener_Chain(); - $chain->add(new Doctrine_EventListener_TestA()); - $chain->add(new Doctrine_EventListener_TestB()); - } -} - -class Doctrine_EventListener_TestA extends Doctrine_EventListener -{ - -} -class Doctrine_EventListener_TestB extends Doctrine_EventListener -{ - -} diff --git a/tests/EventListenerTestCase.php b/tests/EventListenerTestCase.php index 77ba0f8e5..1d25e203b 100644 --- a/tests/EventListenerTestCase.php +++ b/tests/EventListenerTestCase.php @@ -174,21 +174,7 @@ class Doctrine_EventListener_TestCase extends Doctrine_UnitTestCase { } */ } -class EventListenerTest extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn("name", "string", 100); - $this->hasColumn("password", "string", 8); - } - public function setUp() { - //$this->attribute(Doctrine::ATTR_LISTENER, new Doctrine_EventListener_AccessorInvoker()); - } - public function getName($name) { - return strtoupper($name); - } - public function setPassword($password) { - return md5($password); - } -} + class Doctrine_EventListener_TestLogger implements Doctrine_Overloadable, Countable { private $messages = array(); diff --git a/tests/Export/CheckConstraintTestCase.php b/tests/Export/CheckConstraintTestCase.php index 96ae9b321..9540d132d 100644 --- a/tests/Export/CheckConstraintTestCase.php +++ b/tests/Export/CheckConstraintTestCase.php @@ -54,12 +54,3 @@ class Doctrine_Export_CheckConstraint_TestCase extends Doctrine_UnitTestCase } } } -class CheckConstraintTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('price', 'decimal', 2, array('max' => 5000, 'min' => 100)); - $this->hasColumn('discounted_price', 'decimal', 2); - $this->check('price > discounted_price'); - } -} diff --git a/tests/Export/RecordTestCase.php b/tests/Export/RecordTestCase.php index 327d0f174..a78fc7ba0 100644 --- a/tests/Export/RecordTestCase.php +++ b/tests/Export/RecordTestCase.php @@ -98,89 +98,3 @@ class Doctrine_Export_Record_TestCase extends Doctrine_UnitTestCase } } -class ForeignKeyTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', null); - $this->hasColumn('code', 'integer', 4); - $this->hasColumn('content', 'string', 4000); - $this->hasColumn('parent_id', 'integer'); - - $this->hasOne('ForeignKeyTest as Parent', - array('local' => 'parent_id', - 'foreign' => 'id', - 'onDelete' => 'CASCADE', - 'onUpdate' => 'RESTRICT') - ); - - $this->hasMany('ForeignKeyTest as Children', - 'ForeignKeyTest.parent_id'); - - $this->option('type', 'INNODB'); - - } -} -class MysqlGroupMember extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('group_id', 'integer', null, 'primary'); - $this->hasColumn('user_id', 'integer', null, 'primary'); - } -} -class MysqlUser extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', null); - - $this->hasMany('MysqlGroup', 'MysqlGroupMember.group_id'); - } -} -class MysqlGroup extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', null); - - $this->hasMany('MysqlUser', 'MysqlGroupMember.user_id'); - } -} -class ForeignKeyTest2 extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', null); - $this->hasColumn('foreignkey', 'integer'); - - $this->hasOne('ForeignKeyTest', 'ForeignKeyTest2.foreignkey'); - } -} -class MysqlIndexTestRecord extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', null); - $this->hasColumn('code', 'integer', 4); - $this->hasColumn('content', 'string', 4000); - - $this->index('content', array('fields' => 'content', 'type' => 'fulltext')); - $this->index('namecode', array('fields' => array('name', 'code'), - 'type' => 'unique')); - - $this->option('type', 'MYISAM'); - - } -} -class MysqlTestRecord extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', null, 'primary'); - $this->hasColumn('code', 'integer', null, 'primary'); - - $this->option('type', 'INNODB'); - } -} - diff --git a/tests/Export/ReporterTestCase.php b/tests/Export/ReporterTestCase.php index f85d535e3..bc8705e94 100644 --- a/tests/Export/ReporterTestCase.php +++ b/tests/Export/ReporterTestCase.php @@ -1,10 +1,4 @@ export->export('BadLyNamed__Class'); diff --git a/tests/ExpressionTestCase.php b/tests/ExpressionTestCase.php index d1df8c45b..beda3bb5a 100644 --- a/tests/ExpressionTestCase.php +++ b/tests/ExpressionTestCase.php @@ -70,11 +70,4 @@ class Doctrine_Expression_TestCase extends Doctrine_UnitTestCase $this->assertEqual($e->getSql(), "SUBSTR(CONCAT('some', 'one'), 0, 3)"); } } -class ExpressionTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string'); - $this->hasColumn('amount', 'integer'); - } -} + diff --git a/tests/IntegrityActionTestCase.php b/tests/IntegrityActionTestCase.php index 2c6cdc523..8b4cc4806 100644 --- a/tests/IntegrityActionTestCase.php +++ b/tests/IntegrityActionTestCase.php @@ -69,50 +69,3 @@ class Doctrine_IntegrityAction_TestCase extends Doctrine_UnitTestCase $c->delete(); } } -class CascadeDeleteTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string'); - } - public function setUp() - { - $this->hasMany('CascadeDeleteRelatedTest as Related', - array('local' => 'id', - 'foreign' => 'cscd_id')); - } -} -class CascadeDeleteRelatedTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string'); - $this->hasColumn('cscd_id', 'integer'); - } - public function setUp() - { - $this->hasOne('CascadeDeleteTest', array('local' => 'cscd_id', - 'foreign' => 'id', - 'onDelete' => 'CASCADE', - 'onUpdate' => 'SET NULL')); - - $this->hasMany('CascadeDeleteRelatedTest2 as Related', - array('local' => 'id', - 'foreign' => 'cscd_id')); - } -} -class CascadeDeleteRelatedTest2 extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string'); - $this->hasColumn('cscd_id', 'integer'); - } - public function setUp() - { - $this->hasOne('CascadeDeleteRelatedTest', array('local' => 'cscd_id', - 'foreign' => 'id', - 'onDelete' => 'SET NULL')); - } -} - diff --git a/tests/OneTableOneClassInheritanceTestCase.php b/tests/OneTableOneClassInheritanceTestCase.php index 3dc5be8bd..3f41cd99c 100644 --- a/tests/OneTableOneClassInheritanceTestCase.php +++ b/tests/OneTableOneClassInheritanceTestCase.php @@ -44,19 +44,3 @@ class Doctrine_OneTableOneClassInheritance_TestCase extends Doctrine_UnitTestCas $this->assertEqual($sql[1], 'CREATE TABLE concrete_inheritance_test_child (id INTEGER PRIMARY KEY AUTOINCREMENT, age INTEGER, name VARCHAR(2147483647))'); } } -class ConcreteInheritanceTestParent extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string'); - } -} -class ConcreteInheritanceTestChild extends ConcreteInheritanceTestParent -{ - public function setTableDefinition() - { - $this->hasColumn('age', 'integer'); - - parent::setTableDefinition(); - } -} diff --git a/tests/Query/AggregateValueTestCase.php b/tests/Query/AggregateValueTestCase.php index ccc3f9805..c5b3f94f3 100644 --- a/tests/Query/AggregateValueTestCase.php +++ b/tests/Query/AggregateValueTestCase.php @@ -215,13 +215,5 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase } -} -class QueryTest_Item extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('price', 'decimal'); - $this->hasColumn('quantity', 'integer'); - } } ?> diff --git a/tests/Query/ExpressionTestCase.php b/tests/Query/ExpressionTestCase.php index f174ce0bc..413a1a142 100644 --- a/tests/Query/ExpressionTestCase.php +++ b/tests/Query/ExpressionTestCase.php @@ -111,31 +111,3 @@ class Doctrine_Query_Expression_TestCase extends Doctrine_UnitTestCase $this->conn->setAttribute(Doctrine::ATTR_PORTABILITY, Doctrine::PORTABILITY_ALL); } } -class Location extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('lat', 'double', 10, array ()); - $this->hasColumn('lon', 'double', 10, array ()); - } - - public function setUp() - { - $this->hasMany('LocationI18n as LocationI18n', array('local' => 'id', 'foreign' => 'id')); - } -} - -class LocationI18n extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', 50, array()); - $this->hasColumn('id', 'integer', 10, array('primary' => true)); - $this->hasColumn('culture', 'string', 2); - } - - public function setUp() - { - $this->hasOne('Location as Location', array('local' => 'id')); - } -} diff --git a/tests/Record/HookTestCase.php b/tests/Record/HookTestCase.php index 033b62d98..743f466f2 100644 --- a/tests/Record/HookTestCase.php +++ b/tests/Record/HookTestCase.php @@ -100,71 +100,4 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase $this->fail(); } } - } -class SoftDeleteTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', null, array('primary' => true)); - $this->hasColumn('something', 'string', '25', array('notnull' => true, 'unique' => true)); - $this->hasColumn('deleted', 'boolean', 1); - } - public function preDelete($event) - { - $event->skipOperation(); - } - public function postDelete($event) - { - $this->deleted = true; - - $this->save(); - } -} - -class RecordHookTest extends Doctrine_Record -{ - protected $_messages = array(); - - public function setTableDefinition() - { - $this->hasColumn('name', 'string', null, array('primary' => true)); - } - public function preSave($event) - { - $this->_messages[] = __FUNCTION__; - } - public function postSave($event) - { - $this->_messages[] = __FUNCTION__; - } - public function preInsert($event) - { - $this->_messages[] = __FUNCTION__; - } - public function postInsert($event) - { - $this->_messages[] = __FUNCTION__; - } - public function preUpdate($event) - { - $this->_messages[] = __FUNCTION__; - } - public function postUpdate($event) - { - $this->_messages[] = __FUNCTION__; - } - public function preDelete($event) - { - $this->_messages[] = __FUNCTION__; - } - public function postDelete($event) - { - $this->_messages[] = __FUNCTION__; - } - public function pop() - { - return array_pop($this->_messages); - } -} - diff --git a/tests/Record/LockTestCase.php b/tests/Record/LockTestCase.php index 0efbda162..6bb1c1717 100644 --- a/tests/Record/LockTestCase.php +++ b/tests/Record/LockTestCase.php @@ -21,31 +21,3 @@ class Doctrine_Record_Lock_TestCase extends Doctrine_UnitTestCase { $this->pass(); } } - -class Rec1 extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('first_name', 'string', 128, array ()); - } - - public function setUp() - { - $this->ownsOne('Rec2 as Account', array('local' => 'id', 'foreign' => 'user_id')); - } -} - -class Rec2 extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('user_id', 'integer', 10, array ( 'unique' => true,)); - $this->hasColumn('address', 'string', 150, array ()); - } - - public function setUp() - { - $this->ownsOne('Rec1 as User', 'Rec2.user_id'); - } - -} diff --git a/tests/Record/SaveBlankRecordTestCase.php b/tests/Record/SaveBlankRecordTestCase.php index 58aa3afe6..bf125ab3e 100644 --- a/tests/Record/SaveBlankRecordTestCase.php +++ b/tests/Record/SaveBlankRecordTestCase.php @@ -60,61 +60,3 @@ class Doctrine_Record_SaveBlankRecord_TestCase extends Doctrine_UnitTestCase $this->assertTrue(isset($user['id'])); } } - -class MyUserGroup extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('my_user_group'); - - $this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,)); - $this->hasColumn('group_id', 'integer', 4, array ()); - $this->hasColumn('user_id', 'integer', 4, array ()); - } - - public function setUp() - { - $this->hasOne('MyGroup as MyGroup', 'MyUserGroup.group_id'); - $this->hasOne('MyUser as MyUser', 'MyUserGroup.user_id'); - } -} - -class MyGroup extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('my_group'); - - $this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,)); - $this->hasColumn('name', 'string', 255, array ( 'notnull' => true,)); - $this->hasColumn('description', 'string', 4000, array ()); - } - - public function setUp() - { - $this->hasMany('MyUser as users', array('refClass' => 'MyUserGroup', 'local' => 'group_id', 'foreign' => 'user_id')); - } -} - -class MyUser2 extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('my_user'); - - $this->hasColumn('id', 'integer', 4, array ( 'primary' => true, 'autoincrement' => true,)); - $this->hasColumn('username', 'string', 128, array ( 'notnull' => true,)); - $this->hasColumn('algorithm', 'string', 128, array ( 'default' => 'sha1', 'notnull' => true,)); - $this->hasColumn('salt', 'string', 128, array ( 'notnull' => true,)); - $this->hasColumn('password', 'string', 128, array ( 'notnull' => true,)); - $this->hasColumn('created_at', 'timestamp', null, array ()); - $this->hasColumn('last_login', 'timestamp', null, array ()); - $this->hasColumn('is_active', 'boolean', null, array ( 'default' => 1, 'notnull' => true,)); - $this->hasColumn('is_super_admin', 'boolean', null, array ( 'default' => 0, 'notnull' => true,)); - } - - public function setUp() - { - $this->hasMany('MyGroup as groups', array('refClass' => 'MyUserGroup', 'local' => 'user_id', 'foreign' => 'group_id')); - } -} \ No newline at end of file diff --git a/tests/Record/SerializeUnserializeTestCase.php b/tests/Record/SerializeUnserializeTestCase.php index 5581c56f0..120ff8044 100644 --- a/tests/Record/SerializeUnserializeTestCase.php +++ b/tests/Record/SerializeUnserializeTestCase.php @@ -102,37 +102,6 @@ class Doctrine_Record_SerializeUnserialize_TestCase extends Doctrine_UnitTestCas } -class SerializeTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('serialize_test'); - - $this->hasColumn('booltest', 'boolean'); - $this->hasColumn('integertest', 'integer', 4, array('unsigned' => true)); - $this->hasColumn('floattest', 'float'); - $this->hasColumn('stringtest', 'string', 200, array('fixed' => true)); - $this->hasColumn('arraytest', 'array', 10000); - $this->hasColumn('objecttest', 'object'); - $this->hasColumn('blobtest', 'blob'); - $this->hasColumn('clobtest', 'clob'); - $this->hasColumn('timestamptest', 'timestamp'); - $this->hasColumn('timetest', 'time'); - $this->hasColumn('datetest', 'date'); - $this->hasColumn('enumtest', 'enum', 4, - array( - 'values' => array( - 'php', - 'java', - 'python' - ) - ) - ); - $this->hasColumn('gziptest', 'gzip'); - } - -} - class TestObject { @@ -145,10 +114,3 @@ class TestObject } -class TestRecord extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('test'); - } -} diff --git a/tests/Record/ZeroValuesTestCase.php b/tests/Record/ZeroValuesTestCase.php index 94d305140..cf77d375b 100644 --- a/tests/Record/ZeroValuesTestCase.php +++ b/tests/Record/ZeroValuesTestCase.php @@ -77,22 +77,3 @@ class Doctrine_Record_ZeroValues_TestCase extends Doctrine_UnitTestCase } } - -class ZeroValueTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => true,)); - $this->hasColumn('username', 'string', 128, array('notnull' => true,)); - $this->hasColumn('algorithm', 'string', 128, array('default' => 'sha1', 'notnull' => true,)); - $this->hasColumn('salt', 'string', 128, array('notnull' => true,)); - $this->hasColumn('password', 'string', 128, array('notnull' => true,)); - $this->hasColumn('created_at', 'timestamp', null, array()); - $this->hasColumn('last_login', 'timestamp', null, array()); - $this->hasColumn('is_active', 'boolean', null, array('default' => true, 'notnull' => true,)); - $this->hasColumn('is_super_admin', 'boolean', null, array('default' => false, 'notnull' => true,)); - } - - public function setUp() - { } -} diff --git a/tests/RecordFilterTestCase.php b/tests/RecordFilterTestCase.php index ee6a50ae7..7a7d843fa 100644 --- a/tests/RecordFilterTestCase.php +++ b/tests/RecordFilterTestCase.php @@ -1,21 +1,4 @@ setAttribute(Doctrine::ATTR_ACCESSORS, Doctrine::ACCESSOR_BOTH); - - $this->hasColumn("name", "string", 200); - $this->hasColumn("password", "string", 32); - } - public function setPassword($password) { - return md5($password); - } - public function getName($name) { - return strtoupper($name); - } -} - - class Doctrine_Record_Filter_TestCase extends Doctrine_UnitTestCase { public function prepareData() { } public function prepareTables() { } diff --git a/tests/Relation/ManyToMany2TestCase.php b/tests/Relation/ManyToMany2TestCase.php index 69bb832c5..136ecca35 100644 --- a/tests/Relation/ManyToMany2TestCase.php +++ b/tests/Relation/ManyToMany2TestCase.php @@ -132,69 +132,3 @@ class Doctrine_Relation_ManyToMany2_TestCase extends Doctrine_UnitTestCase */ } } - -class TestUser extends Doctrine_Record -{ - public function setUp() - { - $this->hasMany('TestMovie as UserBookmarks', - array('local' => 'user_id', - 'foreign' => 'movie_id', - 'refClass' => 'TestMovieUserBookmark')); - - $this->hasMany('TestMovie as UserVotes', - array('local' => 'user_id', - 'foreign' => 'movie_id', - 'refClass' => 'TestMovieUserVote')); - - } - public function setTableDefinition() - { - $this->hasColumn('name', 'string', 30); - } -} - -class TestMovie extends Doctrine_Record -{ - - public function setUp() - { - $this->hasOne('TestUser as User', - array('local' => 'user_id', - 'foreign' => 'id')); - - $this->hasMany('TestUser as MovieBookmarks', - array('local' => 'movie_id', - 'foreign' => 'user_id', - 'refClass' => 'TestMovieUserBookmark')); - - $this->hasMany('TestUser as MovieVotes', - array('local' => 'movie_id', - 'foreign' => 'user_id', - 'refClass' => 'TestMovieUserVote')); - } - - public function setTableDefinition() - { - $this->hasColumn('user_id', 'integer', null); - $this->hasColumn('name', 'string', 30); - } -} - -class TestMovieUserBookmark extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('user_id', 'integer', null, array('primary' => true)); - $this->hasColumn('movie_id', 'integer', null, array('primary' => true)); - } -} - -class TestMovieUserVote extends Doctrine_Record -{ - public function setTableDefinition() { - $this->hasColumn('vote', 'string', 30); - $this->hasColumn('user_id', 'integer', null, array('primary' => true)); - $this->hasColumn('movie_id', 'integer', null, array('primary' => true)); - } -} diff --git a/tests/Relation/ManyToManyTestCase.php b/tests/Relation/ManyToManyTestCase.php index 9df06d13d..8b8629c5c 100644 --- a/tests/Relation/ManyToManyTestCase.php +++ b/tests/Relation/ManyToManyTestCase.php @@ -1,81 +1,4 @@ hasColumn('name', 'string', 200); - $this->hasColumn('child_id', 'integer'); - } - public function setUp() { - - $this->hasMany('RTC1 as RTC1', 'JC1.c1_id'); - $this->hasMany('RTC2 as RTC2', 'JC1.c1_id'); - $this->hasMany('RTC3 as RTC3', 'JC2.c1_id'); - $this->hasMany('RTC3 as RTC4', 'JC1.c1_id'); - - } -} - -class M2MTest2 extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('oid', 'integer', 11, array('autoincrement', 'primary')); - $this->hasColumn('name', 'string', 20); - } - public function setUp() { - $this->hasMany('RTC4 as RTC5', 'JC3.c1_id'); - } -} - -class JC3 extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('c1_id', 'integer'); - $this->hasColumn('c2_id', 'integer'); - } -} -class JC1 extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('c1_id', 'integer'); - $this->hasColumn('c2_id', 'integer'); - } -} -class JC2 extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('c1_id', 'integer'); - $this->hasColumn('c2_id', 'integer'); - } -} -class RTC1 extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string', 200); - } - public function setUp() { - $this->hasMany('M2MTest as RTC1', 'JC1.c2_id'); - } -} -class RTC2 extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string', 200); - } - public function setUp() { - $this->hasMany('M2MTest as RTC2', 'JC1.c2_id'); - } -} -class RTC3 extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string', 200); - } - public function setUp() { - $this->hasMany('M2MTest as RTC3', 'JC2.c2_id'); - $this->hasMany('M2MTest as RTC4', 'JC1.c2_id'); - } -} -class RTC4 extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('oid', 'integer', 11, array('autoincrement', 'primary')); - $this->hasColumn('name', 'string', 20); - } - public function setUp() { - $this->hasMany('M2MTest2', 'JC3.c2_id'); - } -} class Doctrine_Relation_ManyToMany_TestCase extends Doctrine_UnitTestCase { public function prepareData() { } diff --git a/tests/Relation/OneToManyTestCase.php b/tests/Relation/OneToManyTestCase.php index 1c761615f..587d75733 100644 --- a/tests/Relation/OneToManyTestCase.php +++ b/tests/Relation/OneToManyTestCase.php @@ -116,56 +116,3 @@ class Doctrine_Relation_OneToMany_TestCase extends Doctrine_UnitTestCase $this->assertEqual($auths[0]->Role->name, 'role1'); } } -class Role extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', 20, array('unique' => true)); - } - public function setUp() - { - $this->hasMany('Auth', array('local' => 'id', 'foreign' => 'roleid')); - } -} - -class Auth extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('roleid', 'integer', 10); - $this->hasColumn('name', 'string', 50); - } - public function setUp() - { - $this->hasOne('Role', array('local' => 'roleid', 'foreign' => 'id')); - } -} -class Policy extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('policy_number', 'integer', 11, array('unique' => true)); - } - - public function setUp() - { - $this->hasMany('PolicyAsset as PolicyAssets', array('local' => 'policy_number', - 'foreign' => 'policy_number')); - $this->index('policy_number_index', array('fields' => array('policy_number'))); - } -} -class PolicyAsset extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('policy_number', 'integer', 11); - $this->hasColumn('value', 'float', 10, array ('notblank' => true,)); - } - - public function setUp() - { - $this->hasOne('Policy', array('foreign' => 'policy_number', - 'local' => 'policy_number')); - $this->index('policy_number_index', array('fields' => array('policy_number'))); - } -} diff --git a/tests/RelationTestCase.php b/tests/RelationTestCase.php index c8837d694..1cd812e28 100644 --- a/tests/RelationTestCase.php +++ b/tests/RelationTestCase.php @@ -164,20 +164,3 @@ class Doctrine_Relation_TestCase extends Doctrine_UnitTestCase { $this->assertTrue($user->getTable()->getRelation('Phonenumber') instanceof Doctrine_Relation_ForeignKey); } } -class RelationTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', 200); - $this->hasColumn('child_id', 'integer'); - } -} -class RelationTestChild extends RelationTest -{ - public function setUp() - { - $this->hasOne('RelationTest as Parent', 'RelationTestChild.child_id'); - - $this->ownsMany('RelationTestChild as Children', 'RelationTestChild.child_id'); - } -} diff --git a/tests/SchemaTestCase.php b/tests/SchemaTestCase.php index d4ccd25a4..c20033329 100644 --- a/tests/SchemaTestCase.php +++ b/tests/SchemaTestCase.php @@ -6,7 +6,7 @@ * @version $Id$ * @package Doctrine */ -class Doctrine_SchemaTestCase extends Doctrine_UnitTestCase +class Doctrine_Schema_TestCase extends Doctrine_UnitTestCase { public function testEverySchemaObjectIsThrowingExceptionOnNonPropertyAssignment() @@ -181,7 +181,7 @@ class Doctrine_SchemaTestCase extends Doctrine_UnitTestCase public function testSchemaIsTraversable() { - /* @todo complete */ + /* @todo complete $schema = new Doctrine_Schema(); @@ -197,5 +197,6 @@ class Doctrine_SchemaTestCase extends Doctrine_UnitTestCase } } } + */ } } diff --git a/tests/SequenceTestCase.php b/tests/SequenceTestCase.php index dd93e18d6..572b41ca5 100644 --- a/tests/SequenceTestCase.php +++ b/tests/SequenceTestCase.php @@ -65,17 +65,3 @@ class Doctrine_Sequence_TestCase extends Doctrine_UnitTestCase */ } } -class CustomSequenceRecord extends Doctrine_Record { - public function setTableDefinition() - { - $this->hasColumn('id', 'integer', null, array('primary', 'sequence' => 'custom_seq')); - $this->hasColumn('name', 'string'); - } -} -class SequenceRecord extends Doctrine_Record { - public function setTableDefinition() - { - $this->hasColumn('id', 'integer', null, array('primary', 'sequence')); - $this->hasColumn('name', 'string'); - } -} diff --git a/tests/TemplateTestCase.php b/tests/TemplateTestCase.php index b0335492c..a525d3379 100644 --- a/tests/TemplateTestCase.php +++ b/tests/TemplateTestCase.php @@ -70,34 +70,8 @@ class Doctrine_Template_TestCase extends Doctrine_UnitTestCase $this->assertTrue($user->Email[0] instanceof ConcreteEmail); } } -class ConcreteUser extends Doctrine_Record -{ - public function setUp() - { - $this->loadTemplate('UserTemplate'); - } -} -class ConcreteGroup extends Doctrine_Record -{ - public function setUp() - { - $this->loadTemplate('GroupTemplate'); - } -} -class ConcreteEmail extends Doctrine_Record -{ - public function setUp() - { - $this->loadTemplate('EmailTemplate'); - } -} -class ConcreteGroupUser extends Doctrine_Record -{ - public function setUp() - { - $this->loadTemplate('GroupUserTemplate'); - } -} + +// move these to ../templates? class UserTemplate extends Doctrine_Template { public function setTableDefinition() diff --git a/tests/Ticket/424BTestCase.php b/tests/Ticket/424BTestCase.php index 249fac94c..cc650804e 100644 --- a/tests/Ticket/424BTestCase.php +++ b/tests/Ticket/424BTestCase.php @@ -95,43 +95,3 @@ class Doctrine_Ticket_424B_TestCase extends Doctrine_UnitTestCase } } -class mmrUser_B extends Doctrine_Record -{ - public function setUp() - { - $this->hasMany('mmrGroup_B as Group', array('local' => 'user_id', - 'foreign' => 'group_id', - 'refClass' => 'mmrGroupUser_B')); - - } - - public function setTableDefinition() - { - // Works when - $this->hasColumn('id', 'string', 30, array ( 'primary' => true)); - $this->hasColumn('name', 'string', 30); - } -} - -class mmrGroup_B extends Doctrine_Record -{ - public function setUp() { - $this->hasMany('mmrUser_B', array('local' => 'group_id', - 'foreign' => 'user_id', - 'refClass' => 'mmrGroupUser_B')); - } - public function setTableDefinition() { - // Works when - $this->hasColumn('id', 'string', 30, array ( 'primary' => true)); - $this->hasColumn('name', 'string', 30); - } -} - -class mmrGroupUser_B extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('user_id', 'string', 30, array('primary' => true)); - $this->hasColumn('group_id', 'string', 30, array('primary' => true)); - } -} diff --git a/tests/Ticket/424CTestCase.php b/tests/Ticket/424CTestCase.php index 908247fca..1ba137595 100644 --- a/tests/Ticket/424CTestCase.php +++ b/tests/Ticket/424CTestCase.php @@ -94,45 +94,3 @@ class Doctrine_Ticket_424C_TestCase extends Doctrine_UnitTestCase $this->assertEqual(count($userOfGroupAByName), 2); } } -class mmrUser_C extends Doctrine_Record -{ - public function setUp() - { - $this->hasMany('mmrGroup_C as Group', array('local' => 'user_id', - 'foreign' => 'group_id', - 'refClass' => 'mmrGroupUser_C')); - - } - - public function setTableDefinition() - { - // Works when - $this->hasColumn('u_id as id', 'string', 30, array('primary' => true)); - $this->hasColumn('name', 'string', 30); - } -} - -class mmrGroup_C extends Doctrine_Record -{ - public function setUp() - { - $this->hasMany('mmrUser_C', array('local' => 'group_id', - 'foreign' => 'user_id', - 'refClass' => 'mmrGroupUser_C')); - } - public function setTableDefinition() - { - $this->hasColumn('g_id as id', 'string', 30, array('primary' => true)); - $this->hasColumn('name', 'string', 30); - } -} - -class mmrGroupUser_C extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('user_id', 'string', 30, array('primary' => true)); - $this->hasColumn('group_id', 'string', 30, array('primary' => true)); - } -} - diff --git a/tests/Ticket330TestCase.php b/tests/Ticket330TestCase.php deleted file mode 100644 index aabae93c4..000000000 --- a/tests/Ticket330TestCase.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @category Object Relational Mapping - * @link www.phpdoctrine.com - * @since 1.0 - * @version $Revision$ - */ - -class stNode extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('node_node'); - - $this->hasColumn('title', 'string', 255, array ()); - } - - public function setUp() - { - $this->hasOne('stNodeDetail as detail', 'stNodeDetail.node_id' , array( 'onDelete'=>'cascade')); - } -} - -class stNodeDetail extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('node_detail'); - - $this->hasColumn('node_id', 'integer', 10, array ( 'unique' => true,)); - $this->hasColumn('null_column', 'string', 255, array ('default'=>null)); - $this->hasColumn('is_bool', 'boolean', null, array ('default' => 0,)); - $this->option('type', 'MyISAM'); - } - - public function setUp() - { - $this->hasOne('stNode as node', 'stNodeDetail.article_id', array('foreign' => 'id' , 'onDelete'=>'cascade')); - } -} - - -class Doctrine_Ticket330_TestCase extends Doctrine_UnitTestCase -{ - public function prepareData() - { } - public function prepareTables() - { - $this->tables[] = 'stNode'; - $this->tables[] = 'stNodeDetail'; - parent::prepareTables(); - } - - public function testUnnecessaryQueries() - { - - $node1 = new stNode(); - $node1->set('title', 'first node'); - $node1->detail->set('is_bool', true); - $node1->save(); - - $node2 = new stNode(); - $node2->set('title', 'second node'); - $node2->detail->set('null_column', 'value'); - $node2->detail->set('is_bool', false); - $node2->save(); - - $nodes = Doctrine_Query::create() - ->select('n.title, d.*') - ->from('stNode n, n.detail d') - ->orderby('n.id') - ->execute(); - - $prevCount = $this->dbh->count(); - - - $this->assertEqual($nodes[0]->detail->get('is_bool'), true); - $this->assertEqual($nodes[0]->detail->get('null_column'), null); - - // Unnecessary query is triggered on line before due to null value column. - $this->assertEqual($this->dbh->count(), $prevCount); - - $prevCount = $this->dbh->count(); - - $this->assertEqual($nodes[1]->detail->get('null_column'), 'value'); - $this->assertEqual($nodes[1]->detail->get('is_bool'), false); - - // Unecessary query is triggered on line before due to false value column - $this->assertEqual($this->dbh->count(), $prevCount); - } -} diff --git a/tests/Ticket337TestCase.php b/tests/Ticket337TestCase.php deleted file mode 100644 index 0457c96a8..000000000 --- a/tests/Ticket337TestCase.php +++ /dev/null @@ -1,146 +0,0 @@ -. - */ - -/** - * Doctrine_Template_TestCase - * - * @package Doctrine - * @author Konsta Vesterinen - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @category Object Relational Inheritance - * @link www.phpdoctrine.com - * @since 1.0 - * @version $Revision$ - */ - - -class ReportBase extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('Report'); - $this->hasColumn('id', 'integer',20, 'autoincrement|primary'); - $this->hasColumn('description', 'string',50); - $this->hasColumn('type', 'integer', 11); - } -} - -class Report extends ReportBase -{ - public function setTableDefinition() - { - parent::setTableDefinition(); - $this->option('subclasses', array('ReportA','ReportB')); - } -} - -class ReportA extends ReportBase -{ - public function setUp() - { - parent::setUp(); - $this->option('inheritanceMap', array('type' => 1)); - } - - public function setTableDefinition() - { - parent::setTableDefinition(); - $this->hasColumn('columnreporta', 'string',50); - } -} - -class ReportB extends ReportBase -{ - public function setUp() - { - parent::setUp(); - $this->option('inheritanceMap', array('type' => 2)); - } - - public function setTableDefinition() - { - parent::setTableDefinition(); - $this->hasColumn('columnreportb', 'string',50); - } -} - - -class Doctrine_Ticket337_TestCase extends Doctrine_UnitTestCase -{ - - public function testInit() - { - /*create table*/ - $this->dbh->exec("CREATE Table Report (". - "id INTEGER PRIMARY KEY AUTOINCREMENT,". - "type INTEGER,". - "description varchar(50),". - "columnreporta varchar(50),". - "columnreportb varchar(50))"); - - } - public function testTicket337() - { - $reportA = new ReportA(); - $reportA->set('description',"teste Report A"); - $reportA->set('columnreporta',"somevalueA"); - $reportA->save(); - - $reportB = new ReportB(); - $reportB->set('description',"teste Report B"); - $reportB->set('columnreportb',"somevalueB"); - $reportB->save(); - - - $this->assertTrue($reportA->get('columnreporta') == "somevalueA"); - $this->assertTrue($reportB->get('columnreportb') == "somevalueB"); - - $q = new Doctrine_Query(); - $reportAFromDB = $q->from('Report')->where('id=?')->execute(array($reportA->id))->getFirst(); - - $q = new Doctrine_Query(); - $reportBFromDB = $q->from('Report')->where('id=?')->execute(array($reportB->id))->getFirst(); - - - //same tests as Doctrine_ColumnAggregationInheritance_TestCase::testSubclassReturnedIfInheritanceMatches() - $this->assertTrue(($reportAFromDB instanceof ReportA)); - $this->assertTrue(($reportBFromDB instanceof ReportB)); - - - - $this->assertEqual($reportAFromDB->get('description'),'teste Report A'); - $this->assertEqual($reportBFromDB->get('description'),'teste Report B'); - - try{ - $this->assertEqual($reportAFromDB->get('columnreporta'),'somevalueA'); - }catch(Doctrine_Record_Exception $ex) - { - $this->fail($ex->__toString()); - } - - try{ - $this->assertEqual($reportBFromDB->get('columnreportb'),'somevalueB'); - }catch(Doctrine_Record_Exception $ex) - { - $this->fail($ex->__toString()); - } - } -} diff --git a/tests/Ticket343TestCase.php b/tests/Ticket343TestCase.php deleted file mode 100644 index 1807b9c09..000000000 --- a/tests/Ticket343TestCase.php +++ /dev/null @@ -1,110 +0,0 @@ -. - */ - -/** - * Doctrine_Ticket343_TestCase - * - * @package Doctrine - * @author Lloyd Leung (lleung at carlton decimal ca) - * @author Konsta Vesterinen - * @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_Ticket343_TestCase extends Doctrine_UnitTestCase -{ - public function prepareData() - { } - public function prepareTables() - { } - public function testForeignPkNonId() - { - $member = new Member(); - $subprogram = new SubProgram(); - $newsblast = new NewsBlast(); - - $member->set('name','hello world!'); - $member->set('pin', 'demo1100'); - - $subprogram->set('name', 'SoemthingNew'); - - $newsblast->set('member', $member); - $newsblast->set('subprogram', $subprogram); - $newsblast->set('title', 'Some title here'); - - $newsblast->save(); - - $test->assertEqual($newsblast['subprogram'], 'SomethingNew'); - $test->assertEqual($newsblast['member']['pin'], 'demo1100'); - $test->assertEqual($newsblast['member']['name'], 'hello world!'); - } -} - - -class Member extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('members'); - - $this->hasColumn('pin', 'string', 8, array('primary' => true)); - $this->hasColumn('name', 'string', 254, array('notblank' => true)); - } - - public function setUp() - { - $this->hasMany('NewsBlast as news_blasts', 'NewsBlast.pin'); - } -} - - -class NewsBlast extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('p2m_newsblast'); - $this->hasColumn('pin', 'string', 8, array('primary' => true)); - $this->hasColumn('subprogram_id', 'integer', 10, array()); - $this->hasColumn('title', 'string', 254, array()); - } - - public function setUp() - { - $this->hasOne('SubProgram as subprogram', 'NewsBlast.subprogram_id'); - $this->hasOne('Member as member', 'NewsBlast.pin'); - } -} -class SubProgram extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->setTableName('p2m_subprogram'); - $this->hasColumn('name', 'string', 50, array()); - } - - public function setUp() - { - $this->hasMany('Member as members', 'Member.subprogram_id'); - } -} - diff --git a/tests/TicketNjeroTestCase.php b/tests/TicketNjeroTestCase.php index 2e5781829..667d20658 100644 --- a/tests/TicketNjeroTestCase.php +++ b/tests/TicketNjeroTestCase.php @@ -1,120 +1,41 @@ - - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @category Object Relational Mapping - * @link www.phpdoctrine.com - * @since 1.0 - * @version $Revision$ - */ -class CoverageCodeN extends Doctrine_Record { - - public function setTableDefinition(){ - $this->setTableName('coverage_codes'); - $this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true)); - $this->hasColumn('code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,)); - $this->hasColumn('description', 'string', 4000, array ( 'notnull' => true, 'notblank' => true,)); - } - - public function setUp(){ -# $this->index('code', array('fields' => 'code')); - } -} + + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ -class PolicyCodeN extends Doctrine_Record { - - public function setTableDefinition(){ - $this->setTableName('policy_codes'); - $this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true)); - $this->hasColumn('code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,)); - $this->hasColumn('description', 'string', 4000, array ( 'notnull' => true, 'notblank' => true,)); - } - - public function setUp(){ -# $this->index('code', array('fields' => 'code')); - } -} - -class LiabilityCodeN extends Doctrine_Record { - - public function setTableDefinition(){ - $this->setTableName('liability_codes'); - $this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true)); - $this->hasColumn('code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,)); - $this->hasColumn('description', 'string', 4000, array ( 'notnull' => true, 'notblank' => true,)); - } - - public function setUp(){ -# $this->index('code', array('fields' => 'code')); - } -} - -class PolicyN extends Doctrine_Record { - - public function setTableDefinition(){ - $this->setTableName('policies'); - $this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true)); - $this->hasColumn('rate_id', 'integer', 4, array ( )); - $this->hasColumn('policy_number', 'integer', 4, array ( 'unique' => true, )); - } - - public function setUp(){ - $this->hasOne('RateN', array('local' => 'rate_id', 'foreign' => 'id' )); - } - -} - -class RateN extends Doctrine_Record{ - - public function setTableDefinition(){ - $this->setTableName('rates'); - $this->hasColumn('id', 'integer', 4, array('notnull' => true, 'primary' => true, 'autoincrement' => true)); - $this->hasColumn('policy_code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,)); - $this->hasColumn('coverage_code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,)); - $this->hasColumn('liability_code', 'integer', 4, array ( 'notnull' => true, 'notblank' => true,)); - $this->hasColumn('total_rate', 'float', null, array ( 'notnull' => true, 'notblank' => true,)); - } - - public function setUp(){ -# $this->index('policy_code_idx', array('fields' => 'policy_code')); -# $this->index('coverage_code_idx', array('fields' => 'coverage_code')); -# $this->index('liability_code_idx', array('fields' => 'liability_code')); - $this->hasOne('PolicyCodeN', array('local' => 'policy_code', 'foreign' => 'code' )); - $this->hasOne('CoverageCodeN', array('local' => 'coverage_code', 'foreign' => 'code' )); - $this->hasOne('LiabilityCodeN', array('local' => 'liability_code', 'foreign' => 'code' )); - } - -} - -class Doctrine_TicketNjero_TestCase extends Doctrine_UnitTestCase -{ - public function prepareData() { } - public function prepareTables() +class Doctrine_TicketNjero_TestCase extends Doctrine_UnitTestCase +{ + public function prepareData() { } + public function prepareTables() { - $this->tables[] = 'CoverageCodeN'; - $this->tables[] = 'PolicyCodeN'; - $this->tables[] = 'LiabilityCodeN'; - $this->tables[] = 'PolicyN'; - $this->tables[] = 'RateN'; + $this->tables[] = 'CoverageCodeN'; + $this->tables[] = 'PolicyCodeN'; + $this->tables[] = 'LiabilityCodeN'; + $this->tables[] = 'PolicyN'; + $this->tables[] = 'RateN'; parent::prepareTables(); - } - - public function testHasOneMultiLevelRelations() - { + } + + public function testHasOneMultiLevelRelations() + { $policy_code = new PolicyCodeN(); $policy_code->code = 1; $policy_code->description = "Special Policy"; $policy_code->save(); - + $coverage_code = new CoverageCodeN(); $coverage_code->code = 1; $coverage_code->description = "Full Coverage"; $coverage_code->save(); - + $coverage_code = new CoverageCodeN(); $coverage_code->code = 3; # note we skip 2 $coverage_code->description = "Partial Coverage"; @@ -148,19 +69,19 @@ class Doctrine_TicketNjero_TestCase extends Doctrine_UnitTestCase ->execute() ->getFirst(); - $this->assertEqual($p->rate_id, 1); - $this->assertEqual($p->RateN->id, 1); - $this->assertEqual($p->RateN->policy_code, 1); - $this->assertEqual($p->RateN->coverage_code, 3); # fail + $this->assertEqual($p->rate_id, 1); + $this->assertEqual($p->RateN->id, 1); + $this->assertEqual($p->RateN->policy_code, 1); + $this->assertEqual($p->RateN->coverage_code, 3); # fail $this->assertEqual($p->RateN->liability_code, 1); - - $c = $p->RateN->coverage_code; - $c2 = $p->RateN->CoverageCodeN->code; - $c3 = $p->RateN->coverage_code; - $this->assertEqual($c, $c2); # fail + $c = $p->RateN->coverage_code; + $c2 = $p->RateN->CoverageCodeN->code; + $c3 = $p->RateN->coverage_code; + + $this->assertEqual($c, $c2); # fail $this->assertEqual($c, $c3); # in my app this fails as well, but I can't reproduce this - #echo "Values " . serialize(array($c, $c2, $c3)); + #echo "Values " . serialize(array($c, $c2, $c3)); - } -} ?> + } +}?> diff --git a/tests/TreeStructureTestCase.php b/tests/TreeStructureTestCase.php index c571e9b3c..b90bd0b9f 100644 --- a/tests/TreeStructureTestCase.php +++ b/tests/TreeStructureTestCase.php @@ -126,16 +126,4 @@ class Doctrine_TreeStructure_TestCase extends Doctrine_UnitTestCase } } -class TreeLeaf extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string'); - $this->hasColumn('parent_id', 'integer'); - } - public function setUp() - { - $this->hasOne('TreeLeaf as Parent', 'TreeLeaf.parent_id'); - $this->hasMany('TreeLeaf as Children', 'TreeLeaf.parent_id'); - } -} + diff --git a/tests/classes.php b/tests/classes.php deleted file mode 100644 index e7ba15f17..000000000 --- a/tests/classes.php +++ /dev/null @@ -1,902 +0,0 @@ -ownsOne('Email', array('local' => 'email_id')); - $this->hasMany('Phonenumber', array('local' => 'id', 'foreign' => 'entity_id')); - $this->ownsOne('Account', array('foreign' => 'entity_id')); - $this->hasMany('Entity', array('local' => 'entity1', - 'refClass' => 'EntityReference', - 'foreign' => 'entity2', - 'equal' => true)); - } - public function setTableDefinition() - { - $this->hasColumn('id', 'integer',20, 'autoincrement|primary'); - $this->hasColumn('name', 'string',50); - $this->hasColumn('loginname', 'string',20, array('unique')); - $this->hasColumn('password', 'string',16); - $this->hasColumn('type', 'integer',1); - $this->hasColumn('created', 'integer',11); - $this->hasColumn('updated', 'integer',11); - $this->hasColumn('email_id', 'integer'); -// $this->option('subclasses', array('User','Group')); - $this->setSubclasses(array("User" => array("type" => 0), "Group" => array("type" => 1))); - } -} -class FieldNameTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('someColumn', 'string', 200, array('default' => 'some string')); - $this->hasColumn('someEnum', 'enum', 4, array('default' => 'php', 'values' => array('php', 'java', 'python'))); - $this->hasColumn('someArray', 'array', 100, array('default' => array())); - $this->hasColumn('someObject', 'object', 200, array('default' => new stdClass)); - $this->hasColumn('someInt', 'integer', 20, array('default' => 11)); - } -} -class EntityReference extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('entity1', 'integer', null, 'primary'); - $this->hasColumn('entity2', 'integer', null, 'primary'); - //$this->setPrimaryKey(array('entity1', 'entity2')); - } -} -class Account extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('entity_id', 'integer'); - $this->hasColumn('amount', 'integer'); - } -} - -class EntityAddress extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('user_id', 'integer', null, array('primary' => true)); - $this->hasColumn('address_id', 'integer', null, array('primary' => true)); - } -} - -class Address extends Doctrine_Record -{ - public function setUp() - { - $this->hasMany('User', array('local' => 'address_id', - 'foreign' => 'user_id', - 'refClass' => 'EntityAddress')); - } - public function setTableDefinition() { - $this->hasColumn('address', 'string', 200); - } -} - -// grouptable doesn't extend Doctrine_Table -> Doctrine_Connection -// won't initialize grouptable when Doctrine_Connection->getTable('Group') is called - -class GroupTable { } -class Group extends Entity { - public function setUp() { - parent::setUp(); - $this->hasMany('User', 'Groupuser.user_id'); -// $this->option('inheritanceMap', array('type' => 1)); - } -} -class Error extends Doctrine_Record { - public function setUp() { - $this->ownsMany('Description', 'Description.file_md5', 'file_md5'); - } - public function setTableDefinition() { - $this->hasColumn('message', 'string',200); - $this->hasColumn('code', 'integer',11); - $this->hasColumn('file_md5', 'string',32, 'primary'); - } -} -class Description extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('description', 'string',3000); - $this->hasColumn('file_md5', 'string',32); - } -} -class UserTable extends Doctrine_Table { } -class User extends Entity -{ - public function setUp() - { - parent::setUp(); - $this->hasMany('Address', array('local' => 'user_id', - 'foreign' => 'address_id', - 'refClass' => 'EntityAddress')); - $this->ownsMany('Album', 'Album.user_id'); - $this->ownsMany('Book', 'Book.user_id'); - $this->hasMany('Group', 'Groupuser.group_id'); -// $this->option('inheritanceMap', array('type' => 0)); - } - /** Custom validation */ - public function validate() - { - // Allow only one name! - if ($this->name !== 'The Saint') { - $this->errorStack()->add('name', 'notTheSaint'); - } - } - public function validateOnInsert() - { - if ($this->password !== 'Top Secret') { - $this->errorStack()->add('password', 'pwNotTopSecret'); - } - } - public function validateOnUpdate() - { - if ($this->loginname !== 'Nobody') { - $this->errorStack()->add('loginname', 'notNobody'); - } - } -} -class SelfRefTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', 50); - $this->hasColumn('created_by', 'integer'); - } - public function setUp() - { - $this->hasOne('SelfRefTest as createdBy', array('local' => 'created_by')); - } -} -class Groupuser extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('added', 'integer'); - $this->hasColumn('group_id', 'integer'); - $this->hasColumn('user_id', 'integer'); - } -} -class Phonenumber extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('phonenumber', 'string',20); - $this->hasColumn('entity_id', 'integer'); - } - public function setUp() - { - $this->hasOne('Entity', array('local' => 'entity_id', - 'foreign' => 'id', - 'onDelete' => 'CASCADE')); - } -} - -class Element extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string', 100); - $this->hasColumn('parent_id', 'integer'); - } - public function setUp() { - $this->hasMany('Element as Child', 'Child.parent_id'); - $this->hasOne('Element as Parent', 'Element.parent_id'); - } -} -class Email extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('address', 'string', 150, 'email|unique'); - } -} -class Book extends Doctrine_Record { - public function setUp() { - $this->ownsMany('Author', 'Author.book_id'); - } - public function setTableDefinition() { - $this->hasColumn('user_id', 'integer'); - $this->hasColumn('name', 'string',20); - } -} -class Author extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('book_id', 'integer'); - $this->hasColumn('name', 'string',20); - } -} -class Album extends Doctrine_Record { - public function setUp() { - $this->ownsMany('Song', 'Song.album_id'); - } - public function setTableDefinition() { - $this->hasColumn('user_id', 'integer'); - $this->hasColumn('name', 'string',20); - } -} -class Song extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('album_id', 'integer'); - $this->hasColumn('genre', 'string',20); - $this->hasColumn('title', 'string',30); - } -} - -class Task extends Doctrine_Record { - public function setUp() { - $this->hasMany('Resource as ResourceAlias', 'Assignment.resource_id'); - $this->hasMany('Task as Subtask', 'Subtask.parent_id'); - } - public function setTableDefinition() { - $this->hasColumn('name', 'string',100); - $this->hasColumn('parent_id', 'integer'); - } -} - -class Resource extends Doctrine_Record { - public function setUp() { - $this->hasMany('Task as TaskAlias', 'Assignment.task_id'); - $this->hasMany('ResourceType as Type', 'ResourceReference.type_id'); - } - public function setTableDefinition() { - $this->hasColumn('name', 'string',100); - } -} -class ResourceReference extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('type_id', 'integer'); - $this->hasColumn('resource_id', 'integer'); - } -} -class ResourceType extends Doctrine_Record { - public function setUp() { - $this->hasMany('Resource as ResourceAlias', 'ResourceReference.resource_id'); - } - public function setTableDefinition() { - $this->hasColumn('type', 'string',100); - } -} -class Assignment extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('task_id', 'integer'); - $this->hasColumn('resource_id', 'integer'); - } -} -class Forum_Category extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('root_category_id', 'integer', 10); - $this->hasColumn('parent_category_id', 'integer', 10); - $this->hasColumn('name', 'string', 50); - $this->hasColumn('description', 'string', 99999); - } - public function setUp() { - $this->hasMany('Forum_Category as Subcategory', 'Subcategory.parent_category_id'); - $this->hasOne('Forum_Category as Parent', 'Forum_Category.parent_category_id'); - $this->hasOne('Forum_Category as Rootcategory', 'Forum_Category.root_category_id'); - } -} -class Forum_Board extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('category_id', 'integer', 10); - $this->hasColumn('name', 'string', 100); - $this->hasColumn('description', 'string', 5000); - } - public function setUp() { - $this->hasOne('Forum_Category as Category', 'Forum_Board.category_id'); - $this->ownsMany('Forum_Thread as Threads', 'Forum_Thread.board_id'); - } -} - -class Forum_Entry extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('author', 'string', 50); - $this->hasColumn('topic', 'string', 100); - $this->hasColumn('message', 'string', 99999); - $this->hasColumn('parent_entry_id', 'integer', 10); - $this->hasColumn('thread_id', 'integer', 10); - $this->hasColumn('date', 'integer', 10); - } - public function setUp() { - $this->hasOne('Forum_Entry as Parent', 'Forum_Entry.parent_entry_id'); - $this->hasOne('Forum_Thread as Thread', 'Forum_Entry.thread_id'); - } -} - -class Forum_Thread extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('board_id', 'integer', 10); - $this->hasColumn('updated', 'integer', 10); - $this->hasColumn('closed', 'integer', 1); - } - public function setUp() { - $this->hasOne('Forum_Board as Board', 'Forum_Thread.board_id'); - $this->ownsMany('Forum_Entry as Entries', 'Forum_Entry.thread_id'); - } -} -class App extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string', 32); - $this->hasColumn('user_id', 'integer', 11); - $this->hasColumn('app_category_id', 'integer', 11); - } - public function setUp() { - $this->hasOne('User', 'User.id'); - $this->hasMany('App_Category as Category', 'App_Category.id'); - } -} - -class App_User extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('first_name', 'string', 32); - $this->hasColumn('last_name', 'string', 32); - $this->hasColumn('email', 'string', 128, 'email'); - $this->hasColumn('username', 'string', 16, 'unique, nospace'); - $this->hasColumn('password', 'string', 128, 'notblank'); - $this->hasColumn('country', 'string', 2, 'country'); - $this->hasColumn('zipcode', 'string', 9, 'nospace'); - } - public function setUp() { - $this->hasMany('App', 'App.user_id'); - } -} - -class App_Category extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string', 32); - $this->hasColumn('parent_id', 'integer'); - } - public function setUp() { - $this->hasMany('App', 'App.app_category_id'); - $this->hasMany('App_Category as Parent', 'App_Category.parent_id'); - } -} - -class ORM_TestEntry extends Doctrine_Record { - public function setTableDefinition() { - $this->setTableName('test_entries'); - $this->hasColumn('id', 'integer', 11, 'autoincrement|primary'); - $this->hasColumn('name', 'string', 255); - $this->hasColumn('stamp', 'timestamp'); - $this->hasColumn('amount', 'float'); - $this->hasColumn('itemID', 'integer'); - } - - public function setUp() { - $this->hasOne('ORM_TestItem', 'ORM_TestEntry.itemID'); - } -} - -class ORM_TestItem extends Doctrine_Record { - public function setTableDefinition() { - $this->setTableName('test_items'); - $this->hasColumn('id', 'integer', 11, 'autoincrement|primary'); - $this->hasColumn('name', 'string', 255); - } - - public function setUp() { - - $this->hasOne('ORM_TestEntry', 'ORM_TestEntry.itemID'); - } -} -class ORM_AccessControl extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', 255); - } - public function setUp() - { - $this->hasMany('ORM_AccessGroup as accessGroups', 'ORM_AccessControlsGroups.accessGroupID'); - } -} - -class ORM_AccessGroup extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', 255); - } - public function setUp() - { - $this->hasMany('ORM_AccessControl as accessControls', 'ORM_AccessControlsGroups.accessControlID'); - } -} - -class ORM_AccessControlsGroups extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('accessControlID', 'integer', 11, array('primary' => true)); - $this->hasColumn('accessGroupID', 'integer', 11, array('primary' => true)); - } -} -class EnumTest extends Doctrine_Record -{ - public function setTableDefinition() { - $this->hasColumn('status', 'enum', 11, array('values' => array('open', 'verified', 'closed'))); - $this->hasColumn('text', 'string'); - } - public function setUp() { - $this->hasMany('EnumTest2 as Enum2', array('local' => 'id', 'foreign' => 'enum_test_id')); - $this->hasMany('EnumTest3 as Enum3', array('local' => 'text', 'foreign' => 'text')); - } -} -class EnumTest2 extends Doctrine_Record -{ - public function setTableDefinition() { - $this->hasColumn('status', 'enum', 11, array('values' => array('open', 'verified', 'closed'))); - $this->hasColumn('enum_test_id', 'integer'); - } -} -class EnumTest3 extends Doctrine_Record -{ - public function setTableDefinition() { - $this->hasColumn('text', 'string', 10, array('primary' => true)); - } -} -class FilterTest extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string',100); - } - public function setUp() { - $this->ownsMany('FilterTest2 as filtered', 'FilterTest2.test1_id'); - } -} -class FilterTest2 extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string',100); - $this->hasColumn('test1_id', 'integer'); - } -} -class CustomPK extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('uid', 'integer',11, 'autoincrement|primary'); - $this->hasColumn('name', 'string',255); - } -} -class Log_Entry extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('stamp', 'timestamp'); - $this->hasColumn('status_id', 'integer'); - } - public function setUp() { - $this->hasOne('Log_Status', 'Log_Entry.status_id'); - } -} -class CPK_Test extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string', 255); - } - public function setUp() { - $this->hasMany('CPK_Test2 as Test', 'CPK_Association.test2_id'); - } -} -class CPK_Test2 extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string', 255); - } - public function setUp() { - $this->hasMany('CPK_Test as Test', 'CPK_Association.test1_id'); - } -} -class CPK_Association extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('test1_id', 'integer', 11, 'primary'); - $this->hasColumn('test2_id', 'integer', 11, 'primary'); - } -} -class Log_Status extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string', 255); - } -} -class ValidatorTest extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('mymixed', 'string', 100); - $this->hasColumn('mystring', 'string', 100, 'notnull|unique'); - $this->hasColumn('myarray', 'array', 1000); - $this->hasColumn('myobject', 'object', 1000); - $this->hasColumn('myinteger', 'integer', 11); - $this->hasColumn('myrange', 'integer', 11, array('range' => array(4,123))); - $this->hasColumn('myregexp', 'string', 5, array('regexp' => '/^[0-9]+$/')); - - $this->hasColumn('myemail', 'string', 100, 'email'); - $this->hasColumn('myemail2', 'string', 100, 'email|notblank'); - } -} -class DateTest extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('date', 'date', 20); - } -} -class GzipTest extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('gzip', 'gzip', 100000); - } -} - -class Tag extends Doctrine_Record { - public function setUp() { - $this->hasMany('Photo', 'Phototag.photo_id'); - } - public function setTableDefinition() { - $this->hasColumn('tag', 'string', 100); - } -} -class Photo extends Doctrine_Record { - public function setUp() { - $this->hasMany('Tag', 'Phototag.tag_id'); - } - public function setTableDefinition() { - $this->hasColumn('name', 'string', 100); - } -} - -class Phototag extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('photo_id', 'integer'); - $this->hasColumn('tag_id', 'integer'); - } -} - -class BooleanTest extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('is_working', 'boolean'); - $this->hasColumn('is_working_notnull', 'boolean', 1, array('default' => false, 'notnull' => true)); - } -} -class Data_File extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('filename', 'string'); - $this->hasColumn('file_owner_id', 'integer'); - } - public function setUp() { - $this->hasOne('File_Owner', 'Data_File.file_owner_id'); - } -} -class NotNullTest extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string', 100, 'notnull'); - $this->hasColumn('type', 'integer', 11); - } -} -class File_Owner extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string', 255); - } - public function setUp() { - $this->hasOne('Data_File', 'Data_File.file_owner_id'); - } -} -class MyUser extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string'); - } - public function setUp() { - $this->hasMany('MyOneThing', 'MyOneThing.user_id'); - $this->hasMany('MyOtherThing', 'MyOtherThing.user_id'); - } -} -class MyOneThing extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string'); - $this->hasColumn('user_id', 'integer'); - } - public function setUp() { - $this->hasMany('MyUserOneThing', 'MyUserOneThing.one_thing_id'); - } -} -class MyOtherThing extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('name', 'string'); - $this->hasColumn('user_id', 'integer'); - } - public function setUp() { - $this->hasMany('MyUserOtherThing', 'MyUserOtherThing.other_thing_id'); - } -} -class MyUserOneThing extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('user_id', 'integer'); - $this->hasColumn('one_thing_id', 'integer'); - } -} -class MyUserOtherThing extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('user_id', 'integer'); - $this->hasColumn('other_thing_id', 'integer'); - } -} -class CategoryWithPosition extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('position', 'integer'); - $this->hasColumn('name', 'string', 255); - } - public function setUp() { - $this->ownsMany('BoardWithPosition as Boards', 'BoardWithPosition.category_id'); - } -} -class BoardWithPosition extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('position', 'integer'); - $this->hasColumn('category_id', 'integer'); - } - public function setUp() { - $this->hasOne('CategoryWithPosition as Category', 'BoardWithPosition.category_id'); - } -} -class Package extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('description', 'string', 255); - } - - public function setUp() - { - $this->ownsMany('PackageVersion as Version', 'PackageVersion.package_id'); - } -} -class PackageVersion extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('package_id', 'integer'); - $this->hasColumn('description', 'string', 255); - } - public function setUp() - { - $this->hasOne('Package', 'PackageVersion.package_id'); - $this->hasMany('PackageVersionNotes as Note', 'PackageVersionNotes.package_version_id'); - } -} -class PackageVersionNotes extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('package_version_id', 'integer'); - $this->hasColumn('description', 'string', 255); - } - public function setUp() - { - $this->hasOne('PackageVersion', 'PackageVersionNotes.package_version_id'); - } -} -class NestTest extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string'); - } - public function setUp() - { - $this->hasMany('NestTest as Parents', array('local' => 'child_id', - 'refClass' => 'NestReference', - 'foreign' => 'parent_id')); - $this->hasMany('NestTest as Children', array('local' => 'parent_id', - 'refClass' => 'NestReference', - 'foreign' => 'child_id')); - - $this->hasMany('NestTest as Relatives', array('local' => 'child_id', - 'refClass' => 'NestReference', - 'foreign' => 'parent_id', - 'equal' => true)); - } -} -class NestReference extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('parent_id', 'integer', 4, 'primary'); - $this->hasColumn('child_id', 'integer', 4, 'primary'); - } -} - -class ValidatorTest_Person extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('identifier', 'integer', 4, array('notblank', 'unique')); - $this->hasColumn('is_football_player', 'boolean'); - } - - public function setUp() { - $this->ownsOne('ValidatorTest_FootballPlayer', 'ValidatorTest_FootballPlayer.person_id'); - } -} - -class ValidatorTest_FootballPlayer extends Doctrine_Record { - public function setTableDefinition() { - $this->hasColumn('person_id', 'string', 255); - $this->hasColumn('team_name', 'string', 255); - $this->hasColumn('goals_count', 'integer', 4); - } -} - -class QueryTest_Category extends Doctrine_Record -{ - /** - * The depth of the category inside the tree. - * Non-persistent field. - * - * @var integer - */ - public $depth; - - /** - * Table definition. - */ - public function setTableDefinition() - { - $this->hasColumn('rootCategoryId as rootCategoryId', 'integer', 4, - array('default' => 0)); - $this->hasColumn('parentCategoryId as parentCategoryId', 'integer', 4, - array('notnull', 'default' => 0)); - $this->hasColumn('name as name', 'string', 50, - array('notnull', 'unique')); - $this->hasColumn('position as position', 'integer', 4, - array('default' => 0, 'notnull')); - } - - /** - * Relations definition. - */ - public function setUp() - { - $this->ownsMany('QueryTest_Category as subCategories', 'subCategories.parentCategoryId'); - $this->hasOne('QueryTest_Category as rootCategory', 'QueryTest_Category.rootCategoryId'); - $this->ownsMany('QueryTest_Board as boards', 'QueryTest_Board.categoryId'); - } -} - -class QueryTest_Board extends Doctrine_Record -{ - /** - * Initializes the table definition. - */ - public function setTableDefinition() - { - $this->hasColumn('categoryId as categoryId', 'integer', 4, - array('notnull')); - $this->hasColumn('name as name', 'string', 100, - array('notnull', 'unique')); - $this->hasColumn('lastEntryId as lastEntryId', 'integer', 4, - array('default' => 0, 'notnull')); - $this->hasColumn('position as position', 'integer', 4, - array('default' => 0, 'notnull')); - } - - /** - * Initializes the relations. - */ - public function setUp() - { - $this->hasOne('QueryTest_Category as category', 'QueryTest_Board.categoryId'); - $this->ownsOne('QueryTest_Entry as lastEntry', 'QueryTest_Board.lastEntryId'); - } -} - -class QueryTest_Entry extends Doctrine_Record -{ - /** - * Table structure. - */ - public function setTableDefinition() - { - $this->hasColumn('authorId', 'integer', 4, - array('notnull')); - $this->hasColumn('date', 'integer', 4, - array('notnull')); - } - - /** - * Runtime definition of the relationships to other entities. - */ - public function setUp() - { - $this->hasOne('QueryTest_User as author', 'QueryTest_Entry.authorId'); - } -} - -class QueryTest_User extends Doctrine_Record -{ - - public function setTableDefinition() - { - $this->hasColumn('username as username', 'string', 50, - array('notnull')); - $this->hasColumn('visibleRankId', 'integer', 4); - } - - /** - * Runtime definition of the relationships to other entities. - */ - public function setUp() - { - $this->hasOne('QueryTest_Rank as visibleRank', 'QueryTest_User.visibleRankId'); - $this->hasMany('QueryTest_Rank as ranks', 'QueryTest_UserRank.rankId'); - } -} - -class QueryTest_UserRank extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('rankId', 'integer', 4, array('primary')); - $this->hasColumn('userId', 'integer', 4, array('primary')); - } -} - -class QueryTest_Rank extends Doctrine_Record -{ - /** - * Initializes the table definition. - */ - public function setTableDefinition() - { - $this->hasColumn('title as title', 'string', 100, - array('notnull')); - $this->hasColumn('color as color', 'string', 20, - array('notnull', 'regexp' => '/^[a-zA-Z\-]{3,}|#[0-9a-fA-F]{6}$/D')); - $this->hasColumn('icon as icon', 'string', 50, - array('notnull', 'default' => ' ', 'regexp' => '/^[a-zA-Z0-9_\-]+\.(jpg|gif|png)$/D')); - } - public function setUp() - { - $this->hasMany('QueryTest_User as users', 'QueryTest_UserRank.userId'); - } -} - -class ValidatorTest_ClientModel extends Doctrine_Record { - public function setTableDefinition() { - - $this->hasColumn('id', 'integer', 4, array('notnull' => true, - 'primary' => true, - 'autoincrement' => true, - 'unsigned' => true)); - $this->hasColumn('short_name', 'string', 32, array('notnull' => true, 'notblank', 'unique' => true)); - } - - public function setUp() { - $this->hasMany("ValidatorTest_AddressModel", array('local' => 'client_id', 'foreign' => 'address_id', 'refClass' => 'ValidatorTest_ClientToAddressModel')); - } -} - -class ValidatorTest_ClientToAddressModel extends Doctrine_Record { - - public function setTableDefinition() { - - $this->hasColumn("client_id", "integer", 11, array('primary' => true)); - $this->hasColumn("address_id", "integer", 11, array('primary' => true)); - } - - public function construct(){ - } - - public function setUp() { - } -} - -class ValidatorTest_AddressModel extends Doctrine_Record { - public function setTableDefinition() { - - $this->hasColumn("id", "integer", 11, array('autoincrement' => true, - 'primary' => true - )); - $this->hasColumn('address1', 'string', 255, array('notnull' => true, 'notblank')); - $this->hasColumn('address2', 'string', 255, array('notnull' => true)); - $this->hasColumn('city', 'string', 255, array('notnull' => true, 'notblank')); - $this->hasColumn('state', 'string', 10, array('notnull' => true, 'notblank', 'usstate')); - $this->hasColumn('zip', 'string', 15, array('notnull' => true, 'notblank', 'regexp' => '/^[0-9-]*$/')); - } - - public function setUp() { - $this->hasMany('ValidatorTest_ClientModel', array('local' => 'address_id', 'foreign' => 'client_id', 'refClass' => 'ValidatorTest_ClientToAddressModel')); - } -} - -class NestedSetTest_SingleRootNode extends Doctrine_Record { - - public function setTableDefinition() { - $this->actAs('NestedSet'); - $this->hasColumn('name', 'string', 50, array('notnull')); - } - -} - -?> diff --git a/tests/run.php b/tests/run.php index a5fbd4c92..f6e26fb8e 100644 --- a/tests/run.php +++ b/tests/run.php @@ -29,6 +29,7 @@ function autoload($class) { // create a test case file if it doesn't exist if ( ! file_exists($file)) { + echo "file $file does not exist \n"; $contents = file_get_contents('template.tpl'); $contents = sprintf($contents, $class, $class); @@ -50,9 +51,16 @@ spl_autoload_register(array('Doctrine', 'autoload')); // register the autoloader function above spl_autoload_register('autoload'); -require_once dirname(__FILE__) . '/../models/location.php'; -require_once dirname(__FILE__) . '/../models/Blog.php'; -require_once dirname(__FILE__) . '/classes.php'; +// include the models +$models = new DirectoryIterator(dirname(__FILE__) . '/../models/'); +foreach($models as $key => $file) { + if ($file->isFile() && ! $file->isDot()) { + require_once $file->getPathname(); + } +} +//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'; @@ -65,13 +73,6 @@ $test = new GroupTest('Doctrine Framework Unit Tests'); // DATABASE ABSTRACTION tests -// Temp tests -/** - -$test->addTestCase(new Doctrine_Ticket330_TestCase()); - */ -/** */ - $test->addTestCase(new Doctrine_TicketNjero_TestCase()); // Connection drivers (not yet fully tested) @@ -216,7 +217,7 @@ $test->addTestCase(new Doctrine_EventListener_Chain_TestCase()); $test->addTestCase(new Doctrine_Record_Filter_TestCase()); -$test->addTestCase(new Doctrine_SchemaTestCase()); +$test->addTestCase(new Doctrine_Schema_TestCase()); $test->addTestCase(new Doctrine_Query_Condition_TestCase()); @@ -281,10 +282,7 @@ $test->addTestCase(new Doctrine_Query_AggregateValue_TestCase()); $test->addTestCase(new Doctrine_NewCore_TestCase()); -//$test->addTestCase(new Doctrine_Ticket337_TestCase()); - // Record - $test->addTestCase(new Doctrine_Record_State_TestCase()); $test->addTestCase(new Doctrine_Record_SerializeUnserialize_TestCase()); @@ -310,8 +308,6 @@ $test->addTestCase(new Doctrine_Query_MultipleAggregateValue_TestCase()); $test->addTestCase(new Doctrine_Query_TestCase()); -$test->addTestCase(new Doctrine_Ticket364_TestCase()); - $test->addTestCase(new Doctrine_Query_MysqlSubquery_TestCase()); $test->addTestCase(new Doctrine_Query_PgsqlSubquery_TestCase()); @@ -421,21 +417,21 @@ class MyReporter extends HtmlReporter { ?> run($reporter); $result["path"] = Doctrine::getPath() . DIRECTORY_SEPARATOR; $result["coverage"] = xdebug_get_code_coverage(); xdebug_stop_code_coverage(); file_put_contents("coverage.txt", serialize($result)); -}else{ +} else { $test->run($reporter); }