Commit 063d0f87 authored by zYne's avatar zYne

--no commit message

--no commit message
parent f4462041
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
*/ */
class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase
{ {
public function testDiffForSimpleCollection() public function testDiffForSimpleCollection()
{ {
$coll = Doctrine_Query::create()->from('User u')->orderby('u.id')->execute(); $coll = Doctrine_Query::create()->from('User u')->orderby('u.id')->execute();
...@@ -55,11 +56,13 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase ...@@ -55,11 +56,13 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase
$this->connection->clear(); $this->connection->clear();
$coll = Doctrine_Query::create()->from('User u')->execute(); $coll = Doctrine_Query::create()->from('User u')->execute();
$this->assertEqual($coll->count(), 7); $this->assertEqual($coll->count(), 7);
} }
public function testDiffForOneToManyRelatedCollection() public function testDiffForOneToManyRelatedCollection()
{ {
$q = Doctrine_Query::create()->from('User u LEFT JOIN u.Phonenumber p') $q = new Doctrine_Query();
$q->from('User u LEFT JOIN u.Phonenumber p')
->where('u.id = 8'); ->where('u.id = 8');
$coll = $q->execute(); $coll = $q->execute();
...@@ -67,22 +70,27 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase ...@@ -67,22 +70,27 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($coll->count(), 1); $this->assertEqual($coll->count(), 1);
$this->assertEqual($coll[0]->Phonenumber->count(), 3); $this->assertEqual($coll[0]->Phonenumber->count(), 3);
$this->assertTrue($coll[0]->Phonenumber instanceof Doctrine_Collection);
unset($coll[0]->Phonenumber[0]); unset($coll[0]->Phonenumber[0]);
$coll[0]->Phonenumber->remove(2); $coll[0]->Phonenumber->remove(2);
$this->assertEqual(count($coll[0]->Phonenumber->getSnapshot()), 3);
$coll[0]->save(); $coll[0]->save();
$this->assertEqual($coll[0]->Phonenumber->count(), 1); $this->assertEqual($coll[0]->Phonenumber->count(), 1);
$this->connection->clear(); $this->connection->clear();
$q = new Doctrine_Query();
$q = Doctrine_Query::create()->from('User u LEFT JOIN u.Phonenumber p')->where('u.id = 8'); $q = Doctrine_Query::create()->from('User u LEFT JOIN u.Phonenumber p')->where('u.id = 8');
$coll = $q->execute(); $coll = $q->execute();
$this->assertEqual($coll[0]->Phonenumber->count(), 1); $this->assertEqual($coll[0]->Phonenumber->count(), 1);
} }
public function testDiffForManyToManyRelatedCollection() public function testDiffForManyToManyRelatedCollection()
{ {
$user = new User(); $user = new User();
...@@ -110,4 +118,5 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase ...@@ -110,4 +118,5 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase
$this->assertEqual(count($user->Group->getSnapshot()), 0); $this->assertEqual(count($user->Group->getSnapshot()), 0);
} }
} }
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
*/ */
class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase
{ {
/**
public function testFetchArraySupportsOneToManyRelations() public function testFetchArraySupportsOneToManyRelations()
{ {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
...@@ -80,4 +81,69 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase ...@@ -80,4 +81,69 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase
$this->assertEqual(count($users), 8); $this->assertEqual(count($users), 8);
$this->assertEqual($users[0]['Email']['address'], 'zYne@example.com'); $this->assertEqual($users[0]['Email']['address'], 'zYne@example.com');
} }
public function testFetchArraySupportsOneToOneRelations2()
{
$q = new Doctrine_Query();
$q->select('u.*, e.*')->from('User u')->innerJoin('u.Email e')->where("u.name = 'zYne'");
$users = $q->execute(array(), Doctrine::FETCH_ARRAY);
$this->assertEqual(count($users), 1);
$this->assertEqual($users[0]['Email']['address'], 'zYne@example.com');
}
*/
public function testFetchRecordSupportsOneToOneRelations()
{
$q = new Doctrine_Query();
$q->select('u.*, e.*')->from('User u')->innerJoin('u.Email e');
$count = count($this->dbh);
$users = $q->execute(array(), Doctrine::FETCH_RECORD);
$this->assertEqual(count($users), 8);
$this->assertEqual($users[0]['Email']['address'], 'zYne@example.com');
$this->assertTrue($users[0] instanceof User);
$this->assertTrue($users instanceof Doctrine_Collection);
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN);
$this->assertEqual($users[0]->id, 4);
$this->assertTrue($users[0]['Email'] instanceof Email);
$this->assertEqual($users[0]['email_id'], 1);
$this->assertEqual(count($this->dbh), $count + 1);
}
public function testFetchRecordSupportsOneToManyRelations()
{
$q = new Doctrine_Query();
$q->select('u.*, p.*')->from('User u')->innerJoin('u.Phonenumber p');
$count = count($this->dbh);
$users = $q->execute(array(), Doctrine::FETCH_RECORD);
$this->assertEqual(count($users), 8);
$this->assertTrue($users[0] instanceof User);
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN);
$this->assertTrue($users instanceof Doctrine_Collection);
$this->assertTrue($users[0]->Phonenumber instanceof Doctrine_Collection);
$this->assertEqual(count($this->dbh), $count + 1);
}
public function testFetchRecordSupportsSimpleFetching()
{
$q = new Doctrine_Query();
$q->select('u.*')->from('User u');
$count = count($this->dbh);
$users = $q->execute(array(), Doctrine::FETCH_RECORD);
$this->assertEqual(count($users), 8);
$this->assertTrue($users[0] instanceof User);
$this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN);
$this->assertEqual(count($this->dbh), $count + 1);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment