diff --git a/tests/AccessTestCase.php b/tests/AccessTestCase.php index 949aefda8..c3722568a 100644 --- a/tests/AccessTestCase.php +++ b/tests/AccessTestCase.php @@ -123,4 +123,3 @@ class Doctrine_Access_TestCase extends Doctrine_UnitTestCase $this->assertEqual($user->get('name'), 'Jack'); } } -?> diff --git a/tests/BatchIteratorTestCase.php b/tests/BatchIteratorTestCase.php index 69aee530f..ec08e4f24 100644 --- a/tests/BatchIteratorTestCase.php +++ b/tests/BatchIteratorTestCase.php @@ -85,4 +85,3 @@ class Doctrine_BatchIterator_TestCase extends Doctrine_UnitTestCase { } } -?> diff --git a/tests/CacheFileTestCase.php b/tests/CacheFileTestCase.php index 4c0663ab1..06d869a85 100644 --- a/tests/CacheFileTestCase.php +++ b/tests/CacheFileTestCase.php @@ -57,4 +57,3 @@ class Doctrine_Cache_FileTestCase extends Doctrine_UnitTestCase { } } -?> diff --git a/tests/CacheQuerySqliteTestCase.php b/tests/CacheQuerySqliteTestCase.php index 480f0db77..355da49e1 100644 --- a/tests/CacheQuerySqliteTestCase.php +++ b/tests/CacheQuerySqliteTestCase.php @@ -37,4 +37,3 @@ class Doctrine_Cache_Query_SqliteTestCase extends Doctrine_UnitTestCase { $this->assertEqual($this->cache->count(), 0); } } -?> diff --git a/tests/CacheSqliteTestCase.php b/tests/CacheSqliteTestCase.php index ec7f2e251..be2aece99 100644 --- a/tests/CacheSqliteTestCase.php +++ b/tests/CacheSqliteTestCase.php @@ -107,4 +107,3 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase { } } -?> diff --git a/tests/CollectionOffsetTestCase.php b/tests/CollectionOffsetTestCase.php index a6d527945..5339ebb18 100644 --- a/tests/CollectionOffsetTestCase.php +++ b/tests/CollectionOffsetTestCase.php @@ -74,4 +74,3 @@ class Doctrine_Collection_Offset_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($coll[6]->getState(), Doctrine_Record::STATE_CLEAN); } } -?> diff --git a/tests/CollectionTestCase.php b/tests/CollectionTestCase.php index 6289cc128..298e4ea4e 100644 --- a/tests/CollectionTestCase.php +++ b/tests/CollectionTestCase.php @@ -330,4 +330,3 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase } } -?> diff --git a/tests/CompositePrimaryKeyTestCase.php b/tests/CompositePrimaryKeyTestCase.php index 417436688..ca9668902 100644 --- a/tests/CompositePrimaryKeyTestCase.php +++ b/tests/CompositePrimaryKeyTestCase.php @@ -11,4 +11,3 @@ class Doctrine_Composite_PrimaryKey_TestCase extends Doctrine_UnitTestCase { parent::prepareTables(); } } -?> diff --git a/tests/ConfigurableTestCase.php b/tests/ConfigurableTestCase.php index a559d1624..efd8c4a3d 100644 --- a/tests/ConfigurableTestCase.php +++ b/tests/ConfigurableTestCase.php @@ -215,4 +215,3 @@ class Doctrine_Configurable_TestCase extends Doctrine_UnitTestCase { $this->assertTrue(is_array($this->manager->getAttributes())); } } -?> diff --git a/tests/Connection/ProfilerTestCase.php b/tests/Connection/ProfilerTestCase.php index 45254c800..0a4680e04 100644 --- a/tests/Connection/ProfilerTestCase.php +++ b/tests/Connection/ProfilerTestCase.php @@ -181,4 +181,3 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); } } -?> diff --git a/tests/ConnectionTestCase.php b/tests/ConnectionTestCase.php index 3519605e2..406b44fa4 100644 --- a/tests/ConnectionTestCase.php +++ b/tests/ConnectionTestCase.php @@ -232,4 +232,3 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase $this->assertEqual($this->connection->transaction->getTransactionLevel(),0); } } -?> diff --git a/tests/ConnectionTransactionTestCase.php b/tests/ConnectionTransactionTestCase.php index 4032f56d1..13b6c71ac 100644 --- a/tests/ConnectionTransactionTestCase.php +++ b/tests/ConnectionTransactionTestCase.php @@ -180,4 +180,3 @@ class Doctrine_Connection_Transaction_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($listener->pop(), 'onPreTransactionCommit'); } } -?> diff --git a/tests/CustomPrimaryKeyTestCase.php b/tests/CustomPrimaryKeyTestCase.php index de15b5415..b144f0a82 100644 --- a/tests/CustomPrimaryKeyTestCase.php +++ b/tests/CustomPrimaryKeyTestCase.php @@ -58,4 +58,3 @@ class Doctrine_CustomPrimaryKey_TestCase extends Doctrine_UnitTestCase $this->assertEqual($c->identifier(), array('uid' => 1)); } } -?> diff --git a/tests/CustomResultSetOrderTestCase.php b/tests/CustomResultSetOrderTestCase.php index 43fc2de78..591445058 100644 --- a/tests/CustomResultSetOrderTestCase.php +++ b/tests/CustomResultSetOrderTestCase.php @@ -177,4 +177,3 @@ class Doctrine_CustomResultSetOrder_TestCase extends Doctrine_UnitTestCase { } } } -?> diff --git a/tests/DataDictSqliteTestCase.php b/tests/DataDictSqliteTestCase.php index bd98122ec..3cbeac525 100644 --- a/tests/DataDictSqliteTestCase.php +++ b/tests/DataDictSqliteTestCase.php @@ -61,4 +61,3 @@ class Doctrine_DataDict_Sqlite_TestCase extends Doctrine_UnitTestCase { } } */ -?> diff --git a/tests/DataType/BooleanTestCase.php b/tests/DataType/BooleanTestCase.php index 17288bdec..2f0adfa55 100644 --- a/tests/DataType/BooleanTestCase.php +++ b/tests/DataType/BooleanTestCase.php @@ -116,4 +116,3 @@ class Doctrine_DataType_Boolean_TestCase extends Doctrine_UnitTestCase { } } -?> diff --git a/tests/DataType/EnumTestCase.php b/tests/DataType/EnumTestCase.php index c9296e5c6..8ad85fd4e 100644 --- a/tests/DataType/EnumTestCase.php +++ b/tests/DataType/EnumTestCase.php @@ -200,4 +200,3 @@ class Doctrine_DataType_Enum_TestCase extends Doctrine_UnitTestCase $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.status AS e__status, e.text AS e__text, e2.text AS e2__text FROM enum_test e LEFT JOIN enum_test3 e2 ON e.text = e2.text WHERE e.status = 1"); } } -?> diff --git a/tests/Db/ProfilerTestCase.php b/tests/Db/ProfilerTestCase.php index e84ac7b47..b72a78d9c 100644 --- a/tests/Db/ProfilerTestCase.php +++ b/tests/Db/ProfilerTestCase.php @@ -174,4 +174,3 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); } } -?> diff --git a/tests/DbProfilerTestCase.php b/tests/DbProfilerTestCase.php index f04a28017..a952c1eb9 100644 --- a/tests/DbProfilerTestCase.php +++ b/tests/DbProfilerTestCase.php @@ -135,4 +135,3 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase { $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); } } -?> diff --git a/tests/DriverTestCase.php b/tests/DriverTestCase.php index c52aa1abb..84d11de4f 100644 --- a/tests/DriverTestCase.php +++ b/tests/DriverTestCase.php @@ -197,4 +197,3 @@ class Doctrine_Driver_UnitTestCase extends UnitTestCase { } } } -?> diff --git a/tests/Export/FirebirdTestCase.php b/tests/Export/FirebirdTestCase.php index 0374767af..f98ff8a03 100644 --- a/tests/Export/FirebirdTestCase.php +++ b/tests/Export/FirebirdTestCase.php @@ -90,4 +90,3 @@ class Doctrine_Export_Firebird_TestCase extends Doctrine_UnitTestCase $this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10), type INT, PRIMARY KEY(name, type))'); } } -?> diff --git a/tests/Export/OracleTestCase.php b/tests/Export/OracleTestCase.php index 309e3721b..5539d2ce0 100644 --- a/tests/Export/OracleTestCase.php +++ b/tests/Export/OracleTestCase.php @@ -151,4 +151,3 @@ class Doctrine_Export_Oracle_TestCase extends Doctrine_UnitTestCase $this->assertEqual($sql[0], 'CREATE TABLE sometable (id INT UNIQUE, name VARCHAR2(4), PRIMARY KEY(id), INDEX myindex (id, name))'); } } -?> diff --git a/tests/Export/PgsqlTestCase.php b/tests/Export/PgsqlTestCase.php index 36a89a990..e84d9a1e1 100644 --- a/tests/Export/PgsqlTestCase.php +++ b/tests/Export/PgsqlTestCase.php @@ -96,4 +96,3 @@ class Doctrine_Export_Pgsql_TestCase extends Doctrine_UnitTestCase )); } } -?> diff --git a/tests/Export/SqliteTestCase.php b/tests/Export/SqliteTestCase.php index e12ed3231..9daf3522b 100644 --- a/tests/Export/SqliteTestCase.php +++ b/tests/Export/SqliteTestCase.php @@ -152,4 +152,3 @@ class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase } */ } -?> diff --git a/tests/ExportTestCase.php b/tests/ExportTestCase.php index 0c9af1d90..900cc5c17 100644 --- a/tests/ExportTestCase.php +++ b/tests/ExportTestCase.php @@ -86,4 +86,3 @@ class Doctrine_Export_TestCase extends Doctrine_UnitTestCase } } -?> diff --git a/tests/HookTestCase.php b/tests/HookTestCase.php index 7f2a7c6c6..aa8f59526 100644 --- a/tests/HookTestCase.php +++ b/tests/HookTestCase.php @@ -170,4 +170,3 @@ class Doctrine_Hook_TestCase extends Doctrine_UnitTestCase } } -?> diff --git a/tests/ManagerTestCase.php b/tests/ManagerTestCase.php index 886ce04a4..3fe4a696a 100644 --- a/tests/ManagerTestCase.php +++ b/tests/ManagerTestCase.php @@ -59,4 +59,3 @@ class Doctrine_Manager_TestCase extends Doctrine_UnitTestCase { public function prepareData() { } public function prepareTables() { } } -?> diff --git a/tests/Query/AggregateValueTestCase.php b/tests/Query/AggregateValueTestCase.php index c5b3f94f3..634cd2ccf 100644 --- a/tests/Query/AggregateValueTestCase.php +++ b/tests/Query/AggregateValueTestCase.php @@ -216,4 +216,3 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase } -?> diff --git a/tests/Query/ComponentAliasTestCase.php b/tests/Query/ComponentAliasTestCase.php index 14f6f7c33..aa42702d0 100644 --- a/tests/Query/ComponentAliasTestCase.php +++ b/tests/Query/ComponentAliasTestCase.php @@ -121,4 +121,3 @@ class Doctrine_Query_ComponentAlias_TestCase extends Doctrine_UnitTestCase } } -?> diff --git a/tests/Query/ConditionTestCase.php b/tests/Query/ConditionTestCase.php index 9fbad899e..8bdcdf9bb 100644 --- a/tests/Query/ConditionTestCase.php +++ b/tests/Query/ConditionTestCase.php @@ -118,4 +118,3 @@ class Doctrine_Query_Condition_TestCase extends Doctrine_UnitTestCase $this->assertEqual($query->getQuery(), $sql); } } -?> diff --git a/tests/Query/DeleteTestCase.php b/tests/Query/DeleteTestCase.php index 67e207a16..d1f8a0683 100644 --- a/tests/Query/DeleteTestCase.php +++ b/tests/Query/DeleteTestCase.php @@ -104,4 +104,3 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase $this->assertEqual($q->getQuery(), 'DELETE FROM entity LIMIT 10 OFFSET 20'); } } -?> diff --git a/tests/Query/FromTestCase.php b/tests/Query/FromTestCase.php index 703fbc9f1..d65113df5 100644 --- a/tests/Query/FromTestCase.php +++ b/tests/Query/FromTestCase.php @@ -117,4 +117,3 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, p.id AS p__id, p.phonenumber AS p__phonenumber FROM entity e INNER JOIN groupuser g ON e.id = g.user_id INNER JOIN entity e2 ON e2.id = g.group_id LEFT JOIN phonenumber p ON e2.id = p.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"); } } -?> diff --git a/tests/Query/LimitTestCase.php b/tests/Query/LimitTestCase.php index b71d8853d..9616d3bcc 100644 --- a/tests/Query/LimitTestCase.php +++ b/tests/Query/LimitTestCase.php @@ -302,4 +302,3 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase $this->assertEqual($q->getSql(), "SELECT p.id AS p__id, p.name AS p__name, t.id AS t__id, t.tag AS t__tag FROM photo p LEFT JOIN phototag p2 ON p.id = p2.photo_id LEFT JOIN tag t ON t.id = p2.tag_id WHERE p.id IN (SELECT DISTINCT p3.id FROM photo p3 LEFT JOIN phototag p4 ON p3.id = p4.photo_id LEFT JOIN tag t2 ON t2.id = p4.tag_id ORDER BY t2.id DESC LIMIT 10) ORDER BY t.id DESC"); } } -?> diff --git a/tests/Query/ReferenceModelTestCase.php b/tests/Query/ReferenceModelTestCase.php index 8d42f192d..86ffc5c39 100644 --- a/tests/Query/ReferenceModelTestCase.php +++ b/tests/Query/ReferenceModelTestCase.php @@ -200,4 +200,3 @@ class Doctrine_Query_ReferenceModel_TestCase extends Doctrine_UnitTestCase { } */ } -?> diff --git a/tests/Query/SelectTestCase.php b/tests/Query/SelectTestCase.php index b4c4b309b..f7bd151a7 100644 --- a/tests/Query/SelectTestCase.php +++ b/tests/Query/SelectTestCase.php @@ -231,4 +231,3 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase $this->assertEqual($users[4]->Phonenumber[0]->max, '444 555'); } } -?> diff --git a/tests/Query/SubqueryTestCase.php b/tests/Query/SubqueryTestCase.php index c0eb6490c..08cf5bfb5 100644 --- a/tests/Query/SubqueryTestCase.php +++ b/tests/Query/SubqueryTestCase.php @@ -109,23 +109,22 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase } public function testAggregateFunctionsInOrderByAndHavingWithCount() - { - $q = new Doctrine_Query(); - - $q->select('u.*, COUNT(a.id) num_albums') - ->from('User u') - ->leftJoin('u.Album a') - ->orderby('num_albums desc') - ->groupby('u.id') - ->having('num_albums > 0') - ->limit(5); - - try { - $q->count(); - $this->pass(); - } catch (Doctrine_Exception $e) { - $this->fail(); - } - } + { + $q = new Doctrine_Query(); + + $q->select('u.*, COUNT(a.id) num_albums') + ->from('User u') + ->leftJoin('u.Album a') + ->orderby('num_albums desc') + ->groupby('u.id') + ->having('num_albums > 0') + ->limit(5); + + try { + $q->count(); + $this->pass(); + } catch (Doctrine_Exception $e) { + $this->fail(); + } + } } -?> diff --git a/tests/Query/UpdateTestCase.php b/tests/Query/UpdateTestCase.php index d75ec9470..bf514f67c 100644 --- a/tests/Query/UpdateTestCase.php +++ b/tests/Query/UpdateTestCase.php @@ -81,4 +81,3 @@ class Doctrine_Query_Update_TestCase extends Doctrine_UnitTestCase $this->assertEqual($q->getQuery(), "UPDATE entity SET id = id + 1 WHERE (type = 0)"); } } -?> diff --git a/tests/RawSqlTestCase.php b/tests/RawSqlTestCase.php index 6d6cc7555..b2e2c7a6a 100644 --- a/tests/RawSqlTestCase.php +++ b/tests/RawSqlTestCase.php @@ -249,4 +249,3 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase $this->assertEqual(count($coll), 3); } } -?> diff --git a/tests/RecordFilterTestCase.php b/tests/RecordFilterTestCase.php index 7a7d843fa..2ff44ed30 100644 --- a/tests/RecordFilterTestCase.php +++ b/tests/RecordFilterTestCase.php @@ -43,4 +43,3 @@ class Doctrine_Record_Filter_TestCase extends Doctrine_UnitTestCase { } } -?> diff --git a/tests/RecordTestCase.php b/tests/RecordTestCase.php index 58bba57c3..509118b2b 100644 --- a/tests/RecordTestCase.php +++ b/tests/RecordTestCase.php @@ -47,7 +47,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $user = new User(); $user->name = "Richard Linklater"; - + $rel = $user->getTable()->getRelation('Account'); $this->assertTrue($rel instanceof Doctrine_Relation_ForeignKey); @@ -148,7 +148,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $this->connection->clear(); $gzip = $gzip->getTable()->find($gzip->id); $this->assertEqual($gzip->gzip, "compressed"); - + $gzip->gzip = "compressed 2"; $this->assertEqual($gzip->gzip, "compressed 2"); @@ -162,7 +162,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $test = new FieldNameTest; - + $this->assertEqual($test->someColumn, 'some string'); $this->assertEqual($test->someEnum, 'php'); $this->assertEqual($test->someArray, array()); @@ -174,12 +174,12 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase public function testToArray() { $user = new User(); - + $a = $user->toArray(); $this->assertTrue(is_array($a)); $this->assertTrue(array_key_exists('name', $a)); - + $this->assertEqual($a['name'], null); $this->assertTrue(array_key_exists('id', $a)); @@ -196,7 +196,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $this->assertEqual($a['name'], 'Someone'); $this->assertTrue(array_key_exists('id', $a)); $this->assertTrue(is_numeric($a['id'])); - + $user->refresh(); $a = $user->toArray(); @@ -290,7 +290,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $this->assertEqual($record->entity1, 3); $this->assertEqual($record->identifier(), array("entity1" => 3, "entity2" => 4)); - + $record->entity2 = 5; $record->entity1 = 2; $this->assertEqual($record->state(), Doctrine_Record::STATE_DIRTY); @@ -309,7 +309,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $this->assertEqual($record->entity2, 5); $this->assertEqual($record->entity1, 2); $this->assertEqual($record->identifier(), array("entity1" => 2, "entity2" => 5)); - + $record->refresh(); $this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->entity2, 5); @@ -320,7 +320,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $record->entity2 = 6; $record->entity1 = 2; $record->save(); - + $coll = $this->connection->query("FROM EntityReference"); $this->assertTrue($coll[0] instanceof EntityReference); $this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_CLEAN); @@ -417,7 +417,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $this->assertEqual($fk->getType(), Doctrine_Relation::MANY_AGGREGATE); $this->assertEqual($fk->getForeign(), "parent_id"); $this->assertEqual($fk->getLocal(), "id"); - + $e->name = "parent"; @@ -480,7 +480,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $this->assertEqual($e2->code,2); $this->assertEqual($e2->file_md5, md5(1)); $this->assertEqual($e2->message, 'user error2'); - + $fk = $e->getTable()->getRelation('Description'); $this->assertTrue($fk instanceof Doctrine_Relation_ForeignKey); @@ -501,7 +501,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $this->assertEqual($e2->Description[1]->file_md5, $e2->file_md5); $e->save(); - + $coll = $this->connection->query('FROM Error'); $e = $coll[0]; @@ -518,7 +518,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $this->assertEqual($e->Description[1]->description, 'This is the 2nd description'); // UPDATING - + $e->code = 2; $e->message = 'changed message'; $e->Description[0]->description = '1st changed description'; @@ -542,9 +542,9 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $user = new User(); $user->name = "John Locke"; $user->save(); - + $this->assertTrue(is_numeric($user->id) && $user->id > 0); - + $this->assertTrue($user->getModified() == array()); $this->assertTrue($user->state() == Doctrine_Record::STATE_CLEAN); @@ -720,7 +720,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $user = $this->objTable->find(5); $this->assertTrue($user->Email instanceof Email); $this->assertEqual($user->Email->address, "absolutist@nottodrink.com"); - + $emails = $this->connection->query("FROM Email WHERE Email.id = $id"); //$this->assertEqual(count($emails),0); @@ -822,7 +822,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $this->assertEqual($user->Group->count(), 0); $user = $this->objTable->find(5); $this->assertEqual($user->Group->count(), 0); - + // ACCESSING ASSOCIATION OBJECT PROPERTIES @@ -831,7 +831,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $this->assertTrue($user->Groupuser instanceof Doctrine_Collection); $this->assertTrue($user->Groupuser[0] instanceof Groupuser); - + $user->name = "Jack Daniels"; $user->Group[0]->name = "Group #1"; $user->Group[1]->name = "Group #2"; @@ -839,10 +839,10 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $t2 = time(); $user->Groupuser[0]->added = $t1; $user->Groupuser[1]->added = $t2; - + $this->assertEqual($user->Groupuser[0]->added, $t1); $this->assertEqual($user->Groupuser[1]->added, $t2); - + $user->save(); $user->refresh(); @@ -874,21 +874,20 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase $user = $this->connection->getTable("User")->find(4); $this->assertTrue($user->getIterator() instanceof ArrayIterator); } - + public function testRefreshRelated() { - $user = $this->connection->getTable("User")->find(4); - $user->Address[0]->address = "Address #1"; - $user->Address[1]->address = "Address #2"; - $user->save(); - $this->assertEqual(count($user->Address), 2); - Doctrine_Query::create()->delete()->from('EntityAddress')->where('user_id = ? AND address_id = ?', array($user->id, $user->Address[1]->id))->execute(); - $user->refreshRelated('Address'); - $this->assertEqual(count($user->Address), 1); - Doctrine_Query::create()->delete()->from('EntityAddress')->where('user_id = ? AND address_id = ?', array($user->id, $user->Address[0]->id))->execute(); - $user->refreshRelated(); - $this->assertEqual(count($user->Address), 0); + $user = $this->connection->getTable("User")->find(4); + $user->Address[0]->address = "Address #1"; + $user->Address[1]->address = "Address #2"; + $user->save(); + $this->assertEqual(count($user->Address), 2); + Doctrine_Query::create()->delete()->from('EntityAddress')->where('user_id = ? AND address_id = ?', array($user->id, $user->Address[1]->id))->execute(); + $user->refreshRelated('Address'); + $this->assertEqual(count($user->Address), 1); + Doctrine_Query::create()->delete()->from('EntityAddress')->where('user_id = ? AND address_id = ?', array($user->id, $user->Address[0]->id))->execute(); + $user->refreshRelated(); + $this->assertEqual(count($user->Address), 0); } - + } -?> diff --git a/tests/Relation/AccessTestCase.php b/tests/Relation/AccessTestCase.php index 09683b636..c08f4a15d 100644 --- a/tests/Relation/AccessTestCase.php +++ b/tests/Relation/AccessTestCase.php @@ -6,78 +6,78 @@ class Doctrine_Relation_Access_TestCase extends Doctrine_UnitTestCase { $o2 = new File_Owner(); $o2->name = "owner2"; - $f1 = new Data_File(); + $f1 = new Data_File(); $f1->filename = 'file1'; - $f2 = new Data_File(); + $f2 = new Data_File(); $f2->filename = 'file2'; - $f3 = new Data_File(); + $f3 = new Data_File(); $f3->filename = 'file3'; - + $o1->Data_File->filename = 'file4'; - // multiple left join branches test - $us = array(); - $us[1] = new MyUser(); - $us[1]->name = "user1"; + // multiple left join branches test + $us = array(); + $us[1] = new MyUser(); + $us[1]->name = "user1"; $this->connection->flush(); - // OneThings - $onethings_gs = array( - array(6,1) - ); - $count = 1; - foreach($onethings_gs as $onething_g) { - for($i=$count;$i<$count+$onething_g[0];$i++) { - $d = new MyOneThing(); - $d->name = "onething".$i; - if($onething_g[1]) { - $us[$onething_g[1]]->MyOneThing->add($d); - } - } - $count += $onething_g[0]; - } - // OtherThings - for($i=0;$i<6;$i++) { - $o = new MyOtherThing(); - $o->name = "otherthing".$i; - $us[1]->MyOtherThing->add($o); - } - // UserOneThings - /* Doctrine assigns the foreign keys automatically - $one_id_gs = array( - array(array(2,3,6,5,1), 1) - ); - foreach($one_id_gs as $one_ids) { - foreach($one_ids[0] as $oid) { - $od = new MyUserOneThing(); - $od->one_thing_id = $oid; - $od->user_id = $one_ids[1]; - } - } - // UserOtherThings - $oth_id_gs = array( - array(array(5,4), 1) - ); - foreach($oth_id_gs as $oth_ids) { - foreach($oth_ids[0] as $oid) { - $uo = new MyUserOtherThing(); - $uo->other_thing_id = $oid; - $uo->user_id = $oth_ids[1]; - } - } - */ + // OneThings + $onethings_gs = array( + array(6,1) + ); + $count = 1; + foreach($onethings_gs as $onething_g) { + for($i=$count;$i<$count+$onething_g[0];$i++) { + $d = new MyOneThing(); + $d->name = "onething".$i; + if($onething_g[1]) { + $us[$onething_g[1]]->MyOneThing->add($d); + } + } + $count += $onething_g[0]; + } + // OtherThings + for($i=0;$i<6;$i++) { + $o = new MyOtherThing(); + $o->name = "otherthing".$i; + $us[1]->MyOtherThing->add($o); + } + // UserOneThings + /* Doctrine assigns the foreign keys automatically + $one_id_gs = array( + array(array(2,3,6,5,1), 1) + ); + foreach($one_id_gs as $one_ids) { + foreach($one_ids[0] as $oid) { + $od = new MyUserOneThing(); + $od->one_thing_id = $oid; + $od->user_id = $one_ids[1]; + } + } + // UserOtherThings + $oth_id_gs = array( + array(array(5,4), 1) + ); + foreach($oth_id_gs as $oth_ids) { + foreach($oth_ids[0] as $oid) { + $uo = new MyUserOtherThing(); + $uo->other_thing_id = $oid; + $uo->user_id = $oth_ids[1]; + } + } + */ $this->connection->flush(); $this->connection->clear(); - } - + } + public function prepareTables() { $this->tables += array("MyUser", - "MyOneThing", - "MyUserOneThing", - "MyOtherThing", - "MyUserOtherThing"); + "MyOneThing", + "MyUserOneThing", + "MyOtherThing", + "MyUserOtherThing"); parent::prepareTables(); } - + public function testOneToOneAggregateRelationFetching() { $coll = $this->connection->query("FROM File_Owner.Data_File WHERE File_Owner.name = 'owner1'"); $this->assertTrue(count($coll) == 1); @@ -87,131 +87,129 @@ class Doctrine_Relation_Access_TestCase extends Doctrine_UnitTestCase { } public function testAccessOneToOneFromForeignSide() { - $check = $this->connection->query("FROM File_Owner WHERE File_Owner.name = 'owner1'"); + $check = $this->connection->query("FROM File_Owner WHERE File_Owner.name = 'owner1'"); $owner1 = $this->connection->query("FROM File_Owner.Data_File WHERE File_Owner.name = 'owner1'"); - $owner2 = $this->connection->query("FROM File_Owner.Data_File WHERE File_Owner.name = 'owner2'"); - $this->assertTrue(count($check) == 1); + $owner2 = $this->connection->query("FROM File_Owner.Data_File WHERE File_Owner.name = 'owner2'"); + $this->assertTrue(count($check) == 1); - $this->assertTrue(count($owner2) == 1); + $this->assertTrue(count($owner2) == 1); - $check = $check[0]; - $owner1 = $owner1[0]; - $owner2 = $owner2[0]; - $this->assertEqual($owner1->name, 'owner1'); + $check = $check[0]; + $owner1 = $owner1[0]; + $owner2 = $owner2[0]; + $this->assertEqual($owner1->name, 'owner1'); $this->assertEqual($owner1->id, 1); - $check2 = $this->connection->query("FROM File_Owner WHERE File_Owner.id = ".$owner1->get('id')); - $this->assertEqual(1, count($check2)); - $check2 = $check2[0]; - $this->assertEqual('owner1', $check2->get('name')); + $check2 = $this->connection->query("FROM File_Owner WHERE File_Owner.id = ".$owner1->get('id')); + $this->assertEqual(1, count($check2)); + $check2 = $check2[0]; + $this->assertEqual('owner1', $check2->get('name')); $this->assertTrue(isset($owner1->Data_File)); - $this->assertFalse(isset($owner2->Data_File)); + $this->assertFalse(isset($owner2->Data_File)); $this->assertEqual(1, $check->get('id')); $this->assertEqual(1, $owner1->get('id')); - $this->assertEqual($owner1->get('id'), $check->get('id')); - $this->assertEqual(2, $owner2->get('id')); + $this->assertEqual($owner1->get('id'), $check->get('id')); + $this->assertEqual(2, $owner2->get('id')); } - public function testAccessOneToOneFromLocalSide() { - $check = $this->connection->query("FROM Data_File WHERE Data_File.filename = 'file4'"); + public function testAccessOneToOneFromLocalSide() { + $check = $this->connection->query("FROM Data_File WHERE Data_File.filename = 'file4'"); $file1 = $this->connection->query("FROM Data_File.File_Owner WHERE Data_File.filename = 'file4'"); - $file2 = $this->connection->query("FROM Data_File.File_Owner WHERE Data_File.filename = 'file1'"); - $this->assertTrue(count($check) == 1); - $this->assertTrue(count($file1) == 1); - $this->assertTrue(count($file2) == 1); + $file2 = $this->connection->query("FROM Data_File.File_Owner WHERE Data_File.filename = 'file1'"); + $this->assertTrue(count($check) == 1); + $this->assertTrue(count($file1) == 1); + $this->assertTrue(count($file2) == 1); + + $check = $check[0]; + $file1 = $file1[0]; + $file2 = $file2[0]; + + $check2 = $this->connection->query("FROM Data_File WHERE Data_File.id = ".$file1->get('id')); + $this->assertEqual(1, count($check2)); + $check2 = $check2[0]; + $this->assertEqual('file4', $check2->get('filename')); - $check = $check[0]; - $file1 = $file1[0]; - $file2 = $file2[0]; - - $check2 = $this->connection->query("FROM Data_File WHERE Data_File.id = ".$file1->get('id')); - $this->assertEqual(1, count($check2)); - $check2 = $check2[0]; - $this->assertEqual('file4', $check2->get('filename')); - $this->assertTrue(isset($file1->File_Owner)); - $this->assertFalse(isset($file2->File_Owner)); + $this->assertFalse(isset($file2->File_Owner)); $this->assertEqual(4, $check->get('id')); $this->assertEqual(4, $file1->get('id')); - $this->assertEqual($file1->get('id'), $check->get('id')); - $this->assertEqual(1, $file2->get('id')); + $this->assertEqual($file1->get('id'), $check->get('id')); + $this->assertEqual(1, $file2->get('id')); } - - public function testMultipleLeftJoinBranches() { - $query = "FROM MyUserOtherThing"; - $other = $this->connection->query($query); - $check1 = array(); - foreach($other as $oth) { - if(!isset($check1[$oth->other_thing_id])) { - $check1[$oth->other_thing_id] = array(); - } - $check1[$oth->other_thing_id][$oth->id] = $oth; - } - $query = "FROM MyUserOneThing"; - $ones = $this->connection->query($query); - $check2 = array(); - foreach($ones as $one) { - if(!isset($check2[$one->one_thing_id])) { - $check2[$one->one_thing_id] = array(); - } - $check2[$one->one_thing_id][$one->id] = $one; - } - - $query = "FROM MyUser, - MyUser.MyOneThing, - MyUser.MyOneThing.MyUserOneThing, - MyUser.MyOtherThing, - MyUser.MyOtherThing.MyUserOtherThing"; - $users = $this->connection->query($query); - foreach($users as $u) { - $this->assertEqual($u->MyOtherThing->count(), 6, "incorrect count of MyOtherThing"); - foreach($u->MyOtherThing as $o) { - $in_check = array_key_exists($o->id, $check1); - $wanted_user_thing_count = $in_check ? count($check1[$o->id]) : 0; - $this->assertEqual($o->MyUserOtherThing->count(), $wanted_user_thing_count, "incorrect count of MyUserOtherThing on MyOtherThing"); - foreach($o->MyUserOtherThing as $uo) { - $this->assertEqual($uo->other_thing_id, $o->id, "incorrectly assigned MyOtherThing.id on MyUserOtherThing"); - if($in_check) { - $wanted_user_thing_exists = array_key_exists($uo->id, $check1[$o->id]); - $this->assertTrue($wanted_user_thing_exists, "MyUserOtherThing incorrectly assigned to MyOtherThing."); - if($wanted_user_thing_exists) { - $this->assertEqual($uo->other_thing_id, $check1[$o->id][$uo->id]->user_id, "incorrect value of MyUserOtherThing.user_id"); - $this->assertEqual($uo->other_thing_id, $check1[$o->id][$uo->id]->other_thing_id, "incorrect value of MyUserOtherThing.other_thing_id"); - } - } - } - } - } - - $query = "FROM MyUser, - MyUser.MyOtherThing, - MyUser.MyOtherThing.MyUserOtherThing, - MyUser.MyOneThing, - MyUser.MyOneThing.MyUserOneThing"; - $users = $this->connection->query($query); - foreach($users as $u) { - $this->assertEqual($u->MyOneThing->count(), 6, "incorrect count of MyOneThing"); - foreach($u->MyOneThing as $o) { - $in_check = array_key_exists($o->id, $check2); - $wanted_user_thing_count = $in_check ? count($check2[$o->id]) : 0; - $this->assertEqual($o->MyUserOneThing->count(), $wanted_user_thing_count, "incorrect count of MyUserOneThing on MyOneThing"); - foreach($o->MyUserOneThing as $uo) { - $this->assertEqual($uo->one_thing_id, $o->id, "incorrectly assigned MyOneThing.id on MyUserOneThing"); - if($in_check) { - $wanted_user_thing_exists = array_key_exists($uo->id, $check2[$o->id]); - $this->assertTrue($wanted_user_thing_exists, "MyUserOneThing incorrectly assigned to MyOneThing."); - if($wanted_user_thing_exists) { - $this->assertEqual($uo->one_thing_id, $check2[$o->id][$uo->id]->user_id, "incorrect value of MyUserOneThing.user_id"); - $this->assertEqual($uo->one_thing_id, $check2[$o->id][$uo->id]->one_thing_id, "incorrect value of MyUserOneThing.one_thing_id"); - } - } - } - } - } - } - + + public function testMultipleLeftJoinBranches() { + $query = "FROM MyUserOtherThing"; + $other = $this->connection->query($query); + $check1 = array(); + foreach($other as $oth) { + if(!isset($check1[$oth->other_thing_id])) { + $check1[$oth->other_thing_id] = array(); + } + $check1[$oth->other_thing_id][$oth->id] = $oth; + } + $query = "FROM MyUserOneThing"; + $ones = $this->connection->query($query); + $check2 = array(); + foreach($ones as $one) { + if(!isset($check2[$one->one_thing_id])) { + $check2[$one->one_thing_id] = array(); + } + $check2[$one->one_thing_id][$one->id] = $one; + } + + $query = "FROM MyUser, + MyUser.MyOneThing, + MyUser.MyOneThing.MyUserOneThing, + MyUser.MyOtherThing, + MyUser.MyOtherThing.MyUserOtherThing"; + $users = $this->connection->query($query); + foreach($users as $u) { + $this->assertEqual($u->MyOtherThing->count(), 6, "incorrect count of MyOtherThing"); + foreach($u->MyOtherThing as $o) { + $in_check = array_key_exists($o->id, $check1); + $wanted_user_thing_count = $in_check ? count($check1[$o->id]) : 0; + $this->assertEqual($o->MyUserOtherThing->count(), $wanted_user_thing_count, "incorrect count of MyUserOtherThing on MyOtherThing"); + foreach($o->MyUserOtherThing as $uo) { + $this->assertEqual($uo->other_thing_id, $o->id, "incorrectly assigned MyOtherThing.id on MyUserOtherThing"); + if($in_check) { + $wanted_user_thing_exists = array_key_exists($uo->id, $check1[$o->id]); + $this->assertTrue($wanted_user_thing_exists, "MyUserOtherThing incorrectly assigned to MyOtherThing."); + if($wanted_user_thing_exists) { + $this->assertEqual($uo->other_thing_id, $check1[$o->id][$uo->id]->user_id, "incorrect value of MyUserOtherThing.user_id"); + $this->assertEqual($uo->other_thing_id, $check1[$o->id][$uo->id]->other_thing_id, "incorrect value of MyUserOtherThing.other_thing_id"); + } + } + } + } + } + + $query = "FROM MyUser, + MyUser.MyOtherThing, + MyUser.MyOtherThing.MyUserOtherThing, + MyUser.MyOneThing, + MyUser.MyOneThing.MyUserOneThing"; + $users = $this->connection->query($query); + foreach($users as $u) { + $this->assertEqual($u->MyOneThing->count(), 6, "incorrect count of MyOneThing"); + foreach($u->MyOneThing as $o) { + $in_check = array_key_exists($o->id, $check2); + $wanted_user_thing_count = $in_check ? count($check2[$o->id]) : 0; + $this->assertEqual($o->MyUserOneThing->count(), $wanted_user_thing_count, "incorrect count of MyUserOneThing on MyOneThing"); + foreach($o->MyUserOneThing as $uo) { + $this->assertEqual($uo->one_thing_id, $o->id, "incorrectly assigned MyOneThing.id on MyUserOneThing"); + if($in_check) { + $wanted_user_thing_exists = array_key_exists($uo->id, $check2[$o->id]); + $this->assertTrue($wanted_user_thing_exists, "MyUserOneThing incorrectly assigned to MyOneThing."); + if($wanted_user_thing_exists) { + $this->assertEqual($uo->one_thing_id, $check2[$o->id][$uo->id]->user_id, "incorrect value of MyUserOneThing.user_id"); + $this->assertEqual($uo->one_thing_id, $check2[$o->id][$uo->id]->one_thing_id, "incorrect value of MyUserOneThing.one_thing_id"); + } + } + } + } + } + } } -?> diff --git a/tests/Relation/ManyToManyTestCase.php b/tests/Relation/ManyToManyTestCase.php index 8b8629c5c..149c07e5b 100644 --- a/tests/Relation/ManyToManyTestCase.php +++ b/tests/Relation/ManyToManyTestCase.php @@ -204,4 +204,3 @@ class Doctrine_Relation_ManyToMany_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($component->name, 'changed name'); } } -?> diff --git a/tests/RepositoryTestCase.php b/tests/RepositoryTestCase.php index 328767413..f891858c3 100644 --- a/tests/RepositoryTestCase.php +++ b/tests/RepositoryTestCase.php @@ -1,7 +1,5 @@ diff --git a/tests/TableTestCase.php b/tests/TableTestCase.php index 943745198..098195f4e 100644 --- a/tests/TableTestCase.php +++ b/tests/TableTestCase.php @@ -237,4 +237,3 @@ class Doctrine_Table_TestCase extends Doctrine_UnitTestCase } } -?> diff --git a/tests/Ticket/NjeroTestCase.php b/tests/Ticket/NjeroTestCase.php index 5cbedb7d4..e0cd54e8c 100644 --- a/tests/Ticket/NjeroTestCase.php +++ b/tests/Ticket/NjeroTestCase.php @@ -84,4 +84,3 @@ class Doctrine_Ticket_Njero_TestCase extends Doctrine_UnitTestCase #echo "Values " . serialize(array($c, $c2, $c3)); } -}?> diff --git a/tests/UnitTestCase.php b/tests/UnitTestCase.php index 6d5777f9b..ee5f1025c 100644 --- a/tests/UnitTestCase.php +++ b/tests/UnitTestCase.php @@ -294,4 +294,3 @@ class Doctrine_UnitTestCase extends UnitTestCase $this->init = true; } } -?> diff --git a/tests/ValidatorTestCase.php b/tests/ValidatorTestCase.php index 7086a962c..8337228f2 100644 --- a/tests/ValidatorTestCase.php +++ b/tests/ValidatorTestCase.php @@ -411,4 +411,3 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase $this->manager->setAttribute(Doctrine::ATTR_VLD, false); } } -?> diff --git a/tests/ValueHolderTestCase.php b/tests/ValueHolderTestCase.php index 44f65dccb..44de22447 100644 --- a/tests/ValueHolderTestCase.php +++ b/tests/ValueHolderTestCase.php @@ -58,4 +58,3 @@ class Doctrine_ValueHolder_TestCase extends Doctrine_UnitTestCase { $this->assertTrue($f); } } -?> diff --git a/tests/ViewTestCase.php b/tests/ViewTestCase.php index da9aaf964..03eac75cb 100644 --- a/tests/ViewTestCase.php +++ b/tests/ViewTestCase.php @@ -74,7 +74,5 @@ class Doctrine_View_TestCase extends Doctrine_UnitTestCase public function testConstructor() { - } } -?>