This commit is contained in:
parent
66dce0416d
commit
a0958f7d0e
@ -3,7 +3,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
|
||||
public function prepareData() { }
|
||||
public function prepareTables() {
|
||||
$this->tables = array("Entity", "User");
|
||||
parent::prepareTables();
|
||||
parent::prepareTables();
|
||||
}
|
||||
public function testOffsetMethods() {
|
||||
$user = new User();
|
||||
@ -14,7 +14,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$user->save();
|
||||
|
||||
$user = $this->session->getTable("User")->find($user->getID());
|
||||
$user = $this->connection->getTable("User")->find($user->getID());
|
||||
$this->assertEqual($user->name,"Jack");
|
||||
|
||||
$user["name"] = "Jack";
|
||||
@ -32,7 +32,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$user->save();
|
||||
|
||||
$user = $this->session->getTable("User")->find($user->getID());
|
||||
$user = $this->connection->getTable("User")->find($user->getID());
|
||||
$this->assertEqual($user->name,"Jack");
|
||||
|
||||
$user->name = "Jack";
|
||||
@ -49,7 +49,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$user->save();
|
||||
|
||||
$user = $this->session->getTable("User")->find($user->getID());
|
||||
$user = $this->connection->getTable("User")->find($user->getID());
|
||||
|
||||
$this->assertEqual($user->get("name"),"Jack");
|
||||
|
||||
|
@ -9,7 +9,7 @@ class Doctrine_BatchIteratorTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testIterator() {
|
||||
$graph = new Doctrine_Query($this->session);
|
||||
$graph = new Doctrine_Query($this->connection);
|
||||
$entities = $graph->query("FROM Entity");
|
||||
$i = 0;
|
||||
foreach($entities as $entity) {
|
||||
|
@ -5,12 +5,12 @@ class Doctrine_Cache_Query_SqliteTestCase extends Doctrine_UnitTestCase {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->manager->setAttribute(Doctrine::ATTR_CACHE,Doctrine::CACHE_NONE);
|
||||
$dir = $this->session->getAttribute(Doctrine::ATTR_CACHE_DIR);
|
||||
$dir = $this->connection->getAttribute(Doctrine::ATTR_CACHE_DIR);
|
||||
|
||||
if(file_exists($dir.DIRECTORY_SEPARATOR."stats.cache"))
|
||||
unlink($dir.DIRECTORY_SEPARATOR."stats.cache");
|
||||
|
||||
$this->cache = new Doctrine_Cache_Query_Sqlite($this->session);
|
||||
$this->cache = new Doctrine_Cache_Query_Sqlite($this->connection);
|
||||
$this->cache->deleteAll();
|
||||
}
|
||||
public function testStore() {
|
||||
|
@ -5,7 +5,7 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->manager->setAttribute(Doctrine::ATTR_CACHE,Doctrine::CACHE_NONE);
|
||||
$dir = $this->session->getAttribute(Doctrine::ATTR_CACHE_DIR);
|
||||
$dir = $this->connection->getAttribute(Doctrine::ATTR_CACHE_DIR);
|
||||
|
||||
if(file_exists($dir.DIRECTORY_SEPARATOR."stats.cache"))
|
||||
unlink($dir.DIRECTORY_SEPARATOR."stats.cache");
|
||||
|
@ -2,7 +2,7 @@
|
||||
class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
|
||||
public function testExpand() {
|
||||
|
||||
$users = $this->session->query("FROM User-o");
|
||||
$users = $this->connection->query("FROM User-o");
|
||||
$this->assertTrue($users instanceof Doctrine_Collection_Offset);
|
||||
|
||||
$this->assertEqual(count($users), 5);
|
||||
@ -11,9 +11,9 @@ class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($users[5]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$users[5];
|
||||
|
||||
$this->session->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
|
||||
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
|
||||
|
||||
$users = $this->session->query("FROM User-o");
|
||||
$users = $this->connection->query("FROM User-o");
|
||||
$this->assertEqual(count($users), 3);
|
||||
$this->assertEqual($users[0]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($users[1]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
@ -39,8 +39,8 @@ class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($users[5]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
|
||||
|
||||
$this->session->setAttribute(Doctrine::ATTR_COLL_LIMIT, 1);
|
||||
$users = $this->session->query("FROM User-b, User.Phonenumber-o WHERE User.".$this->objTable->getIdentifier()." = 5");
|
||||
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 1);
|
||||
$users = $this->connection->query("FROM User-b, User.Phonenumber-o WHERE User.".$this->objTable->getIdentifier()." = 5");
|
||||
|
||||
$this->assertEqual(count($users), 1);
|
||||
|
||||
@ -54,8 +54,8 @@ class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testGetIterator() {
|
||||
$this->session->setAttribute(Doctrine::ATTR_COLL_LIMIT, 4);
|
||||
$coll = $this->session->query("FROM User-o");
|
||||
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 4);
|
||||
$coll = $this->connection->query("FROM User-o");
|
||||
|
||||
foreach($coll as $user) {
|
||||
}
|
||||
@ -63,9 +63,9 @@ class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($coll[3]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($coll[6]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
|
||||
$this->session->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
|
||||
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
|
||||
|
||||
$coll = $this->session->query("FROM User-o");
|
||||
$coll = $this->connection->query("FROM User-o");
|
||||
|
||||
foreach($coll as $user) {
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testLoadRelatedForAssociation() {
|
||||
$coll = $this->session->query("FROM User");
|
||||
$coll = $this->connection->query("FROM User");
|
||||
|
||||
$this->assertEqual($coll->count(), 8);
|
||||
|
||||
@ -34,9 +34,9 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$coll->save();
|
||||
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
|
||||
$coll = $this->session->query("FROM User");
|
||||
$coll = $this->connection->query("FROM User");
|
||||
|
||||
$this->assertEqual($coll->count(), 8);
|
||||
$this->assertEqual($coll[0]->Group->count(), 2);
|
||||
@ -44,9 +44,9 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($coll[2]->Group->count(), 3);
|
||||
$this->assertEqual($coll[5]->Group->count(), 3);
|
||||
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
|
||||
$coll = $this->session->query("FROM User");
|
||||
$coll = $this->connection->query("FROM User");
|
||||
|
||||
$this->assertEqual($coll->count(), 8);
|
||||
|
||||
@ -67,10 +67,10 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$this->assertEqual(($count + 1), $this->dbh->count());
|
||||
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
}
|
||||
public function testLoadRelated() {
|
||||
$coll = $this->session->query("FROM User(id)");
|
||||
$coll = $this->connection->query("FROM User(id)");
|
||||
|
||||
$q = $coll->loadRelated();
|
||||
|
||||
@ -86,7 +86,7 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($count, $this->dbh->count());
|
||||
}
|
||||
public function testLoadRelatedForLocalKeyRelation() {
|
||||
$coll = $this->session->query("FROM User");
|
||||
$coll = $this->connection->query("FROM User");
|
||||
|
||||
$this->assertEqual($coll->count(), 8);
|
||||
|
||||
@ -107,10 +107,10 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$this->assertEqual(($count + 1), $this->dbh->count());
|
||||
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
}
|
||||
public function testLoadRelatedForForeignKey() {
|
||||
$coll = $this->session->query("FROM User");
|
||||
$coll = $this->connection->query("FROM User");
|
||||
$this->assertEqual($coll->count(), 8);
|
||||
|
||||
$count = $this->dbh->count();
|
||||
@ -139,16 +139,16 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$this->assertEqual(($count + 1), $this->dbh->count());
|
||||
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
}
|
||||
public function testCount() {
|
||||
$coll = new Doctrine_Collection($this->session->getTable('User'));
|
||||
$coll = new Doctrine_Collection($this->connection->getTable('User'));
|
||||
$this->assertEqual($coll->count(), 0);
|
||||
$coll[0];
|
||||
$this->assertEqual($coll->count(), 1);
|
||||
}
|
||||
public function testExpand() {
|
||||
$users = $this->session->query("FROM User-b.Phonenumber-l WHERE User.Phonenumber.phonenumber LIKE '%123%'");
|
||||
$users = $this->connection->query("FROM User-b.Phonenumber-l WHERE User.Phonenumber.phonenumber LIKE '%123%'");
|
||||
|
||||
$this->assertTrue($users instanceof Doctrine_Collection_Batch);
|
||||
$this->assertTrue($users[1] instanceof User);
|
||||
@ -174,7 +174,7 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
|
||||
$coll->setGenerator($generator);
|
||||
$generator = $coll->getGenerator();
|
||||
|
||||
$user = $this->session->getTable("User")->find(4);
|
||||
$user = $this->connection->getTable("User")->find(4);
|
||||
$this->assertEqual($generator->getIndex($user), 4);
|
||||
|
||||
}
|
||||
@ -190,8 +190,8 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($coll["name"], $user);
|
||||
|
||||
|
||||
$this->session->getTable("email")->setAttribute(Doctrine::ATTR_COLL_KEY,"address");
|
||||
$emails = $this->session->getTable("email")->findAll();
|
||||
$this->connection->getTable("email")->setAttribute(Doctrine::ATTR_COLL_KEY,"address");
|
||||
$emails = $this->connection->getTable("email")->findAll();
|
||||
foreach($emails as $k => $v) {
|
||||
$this->assertTrue(gettype($k), "string");
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ class Doctrine_ConfigurableTestCase extends Doctrine_UnitTestCase {
|
||||
public function prepareTables() { }
|
||||
public function prepareData() { }
|
||||
public function testSetAttribute() {
|
||||
$table = $this->session->getTable("User");
|
||||
$table = $this->connection->getTable("User");
|
||||
|
||||
$this->manager->setAttribute(Doctrine::ATTR_CACHE_TTL,100);
|
||||
$this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_CACHE_TTL),100);
|
||||
@ -52,11 +52,11 @@ class Doctrine_ConfigurableTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
try {
|
||||
$this->session->beginTransaction();
|
||||
$this->connection->beginTransaction();
|
||||
$this->manager->setAttribute(Doctrine::ATTR_LOCKMODE, Doctrine::LOCK_OPTIMISTIC);
|
||||
} catch(Exception $e) {
|
||||
$this->assertTrue($e instanceof Exception);
|
||||
$this->session->commit();
|
||||
$this->connection->commit();
|
||||
}
|
||||
|
||||
$e = false;
|
||||
@ -82,11 +82,11 @@ class Doctrine_ConfigurableTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$e = false;
|
||||
try {
|
||||
$this->session->beginTransaction();
|
||||
$this->session->setAttribute(Doctrine::ATTR_LOCKMODE, Doctrine::LOCK_PESSIMISTIC);
|
||||
$this->connection->beginTransaction();
|
||||
$this->connection->setAttribute(Doctrine::ATTR_LOCKMODE, Doctrine::LOCK_PESSIMISTIC);
|
||||
} catch(Exception $e) {
|
||||
$this->assertTrue($e instanceof Exception);
|
||||
$this->session->commit();
|
||||
$this->connection->commit();
|
||||
}
|
||||
try {
|
||||
$this->manager->setAttribute(Doctrine::ATTR_PK_TYPE,-12);
|
||||
|
@ -1,94 +1,94 @@
|
||||
<?php
|
||||
require_once("UnitTestCase.php");
|
||||
class Doctrine_SessionTestCase extends Doctrine_UnitTestCase {
|
||||
class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
public function testBuildFlushTree() {
|
||||
$correct = array("Task","ResourceType","Resource","Assignment","ResourceReference");
|
||||
|
||||
$task = new Task();
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Task"));
|
||||
$tree = $this->connection->buildFlushTree(array("Task"));
|
||||
$this->assertEqual($tree,array("Resource","Task","Assignment"));
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Task","Resource"));
|
||||
$tree = $this->connection->buildFlushTree(array("Task","Resource"));
|
||||
$this->assertEqual($tree,$correct);
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Task","Assignment","Resource"));
|
||||
$tree = $this->connection->buildFlushTree(array("Task","Assignment","Resource"));
|
||||
$this->assertEqual($tree,$correct);
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Assignment","Task","Resource"));
|
||||
$tree = $this->connection->buildFlushTree(array("Assignment","Task","Resource"));
|
||||
$this->assertEqual($tree,$correct);
|
||||
|
||||
|
||||
$correct = array("Forum_Category","Forum_Board","Forum_Thread");
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Board"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Category","Forum_Board"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Category","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$correct = array("Forum_Category","Forum_Board","Forum_Thread","Forum_Entry");
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Entry","Forum_Board"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Entry","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Board","Forum_Entry"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Board","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Thread","Forum_Board"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Thread","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Board","Forum_Thread"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Board","Forum_Thread"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Board","Forum_Thread","Forum_Entry"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Board","Forum_Thread","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Board","Forum_Entry","Forum_Thread"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Board","Forum_Entry","Forum_Thread"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Entry","Forum_Board","Forum_Thread"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Entry","Forum_Board","Forum_Thread"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Entry","Forum_Thread","Forum_Board"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Entry","Forum_Thread","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Thread","Forum_Board","Forum_Entry"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Thread","Forum_Board","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Thread","Forum_Entry","Forum_Board"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Thread","Forum_Entry","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Board","Forum_Thread","Forum_Category"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Board","Forum_Thread","Forum_Category"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Category","Forum_Thread","Forum_Board"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Category","Forum_Thread","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Thread","Forum_Board","Forum_Category"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Thread","Forum_Board","Forum_Category"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Board","Forum_Thread","Forum_Category","Forum_Entry"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Board","Forum_Thread","Forum_Category","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Board","Forum_Thread","Forum_Entry","Forum_Category"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Board","Forum_Thread","Forum_Entry","Forum_Category"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Board","Forum_Category","Forum_Thread","Forum_Entry"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Board","Forum_Category","Forum_Thread","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Entry","Forum_Thread","Forum_Board","Forum_Category"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Entry","Forum_Thread","Forum_Board","Forum_Category"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Entry","Forum_Thread","Forum_Category","Forum_Board"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Entry","Forum_Thread","Forum_Category","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Entry","Forum_Category","Forum_Board","Forum_Thread"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Entry","Forum_Category","Forum_Board","Forum_Thread"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Thread","Forum_Category","Forum_Board","Forum_Entry"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Thread","Forum_Category","Forum_Board","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Thread","Forum_Entry","Forum_Category","Forum_Board"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Thread","Forum_Entry","Forum_Category","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Thread","Forum_Board","Forum_Entry","Forum_Category"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Thread","Forum_Board","Forum_Entry","Forum_Category"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Category","Forum_Entry","Forum_Board","Forum_Thread"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Category","Forum_Entry","Forum_Board","Forum_Thread"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Category","Forum_Thread","Forum_Entry","Forum_Board"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Category","Forum_Thread","Forum_Entry","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->session->buildFlushTree(array("Forum_Category","Forum_Board","Forum_Thread","Forum_Entry"));
|
||||
$tree = $this->connection->buildFlushTree(array("Forum_Category","Forum_Board","Forum_Thread","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
}
|
||||
@ -104,12 +104,12 @@ class Doctrine_SessionTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testFlush() {
|
||||
$user = $this->session->getTable("User")->find(4);
|
||||
$user = $this->connection->getTable("User")->find(4);
|
||||
$this->assertTrue(is_numeric($user->Phonenumber[0]->entity_id));
|
||||
|
||||
$user = $this->session->create("Email");
|
||||
$user = $this->session->create("User");
|
||||
$record = $this->session->create("Phonenumber");
|
||||
$user = $this->connection->create("Email");
|
||||
$user = $this->connection->create("User");
|
||||
$record = $this->connection->create("Phonenumber");
|
||||
|
||||
$user->Email->address = "example@drinkmore.info";
|
||||
$this->assertTrue($user->email_id instanceof Email);
|
||||
@ -129,7 +129,7 @@ class Doctrine_SessionTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertTrue($user->Phonenumber[0]->entity_id instanceof User);
|
||||
$this->assertTrue($user->Phonenumber[2]->entity_id instanceof User);
|
||||
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
|
||||
$this->assertTrue(is_numeric($user->Phonenumber[0]->entity_id));
|
||||
|
||||
@ -151,7 +151,7 @@ class Doctrine_SessionTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$user = $this->objTable->find(5);
|
||||
|
||||
$pf = $this->session->getTable("Phonenumber");
|
||||
$pf = $this->connection->getTable("Phonenumber");
|
||||
|
||||
$this->assertTrue($user->Phonenumber instanceof Doctrine_Collection);
|
||||
$this->assertTrue($user->Phonenumber->count() == 3);
|
||||
@ -161,7 +161,7 @@ class Doctrine_SessionTestCase extends Doctrine_UnitTestCase {
|
||||
$user->Phonenumber = $coll;
|
||||
$this->assertTrue($user->Phonenumber->count() == 0);
|
||||
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
unset($user);
|
||||
$user = $this->objTable->find(5);
|
||||
|
||||
@ -173,7 +173,7 @@ class Doctrine_SessionTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertTrue(is_numeric($user->Phonenumber[0]->entity_id));
|
||||
|
||||
$user->Phonenumber[1]->phonenumber = "123 123";
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
|
||||
|
||||
$this->assertEqual($user->Phonenumber->count(), 2);
|
||||
@ -183,7 +183,7 @@ class Doctrine_SessionTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($user->Phonenumber->count(), 2);
|
||||
|
||||
$user->Phonenumber[3]->phonenumber = "123 123";
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
|
||||
$this->assertEqual($user->Phonenumber->count(), 3);
|
||||
unset($user);
|
||||
@ -205,7 +205,7 @@ class Doctrine_SessionTestCase extends Doctrine_UnitTestCase {
|
||||
$user->Phonenumber["work"]->phonenumber = "444 444";
|
||||
|
||||
$this->assertEqual($user->Phonenumber->count(), 2);
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
|
||||
$this->assertEqual($user->Phonenumber->count(), 2);
|
||||
unset($user);
|
||||
@ -224,7 +224,7 @@ class Doctrine_SessionTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
|
||||
$user->Phonenumber = $coll;
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
$this->assertEqual($user->Phonenumber->count(), 3);
|
||||
$user = $this->objTable->find(5);
|
||||
$this->assertEqual($user->Phonenumber->count(), 3);
|
||||
@ -234,7 +234,7 @@ class Doctrine_SessionTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$user->Email->address = "drinker@drinkmore.info";
|
||||
$this->assertTrue($user->Email instanceof Email);
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
$this->assertTrue($user->Email instanceof Email);
|
||||
$user = $this->objTable->find(5);
|
||||
$this->assertEqual($user->Email->address, "drinker@drinkmore.info");
|
||||
@ -242,87 +242,87 @@ class Doctrine_SessionTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
// REPLACING ONE-TO-ONE REFERENCES
|
||||
|
||||
$email = $this->session->create("Email");
|
||||
$email = $this->connection->create("Email");
|
||||
$email->address = "absolutist@nottodrink.com";
|
||||
$user->Email = $email;
|
||||
|
||||
$this->assertTrue($user->Email instanceof Email);
|
||||
$this->assertEqual($user->Email->address, "absolutist@nottodrink.com");
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
unset($user);
|
||||
|
||||
$user = $this->objTable->find(5);
|
||||
$this->assertTrue($user->Email instanceof Email);
|
||||
$this->assertEqual($user->Email->address, "absolutist@nottodrink.com");
|
||||
|
||||
$emails = $this->session->query("FROM Email WHERE Email.id = $id");
|
||||
$emails = $this->connection->query("FROM Email WHERE Email.id = $id");
|
||||
//$this->assertEqual(count($emails),0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testGetManager() {
|
||||
$this->assertEqual($this->session->getManager(),$this->manager);
|
||||
$this->assertEqual($this->connection->getManager(),$this->manager);
|
||||
}
|
||||
public function testQuery() {
|
||||
$this->assertTrue($this->session->query("FROM User") instanceof Doctrine_Collection);
|
||||
$this->assertTrue($this->connection->query("FROM User") instanceof Doctrine_Collection);
|
||||
}
|
||||
|
||||
public function testDelete() {
|
||||
$user = $this->session->create("User");
|
||||
$this->session->delete($user);
|
||||
$user = $this->connection->create("User");
|
||||
$this->connection->delete($user);
|
||||
$this->assertEqual($user->getState(),Doctrine_Record::STATE_TCLEAN);
|
||||
}
|
||||
public function testGetTable() {
|
||||
$table = $this->session->getTable("Group");
|
||||
$table = $this->connection->getTable("Group");
|
||||
$this->assertTrue($table instanceof Doctrine_Table);
|
||||
try {
|
||||
$table = $this->session->getTable("Unknown");
|
||||
$table = $this->connection->getTable("Unknown");
|
||||
$f = false;
|
||||
} catch(Doctrine_Exception $e) {
|
||||
$f = true;
|
||||
}
|
||||
$this->assertTrue($f);
|
||||
|
||||
$table = $this->session->getTable("User");
|
||||
$table = $this->connection->getTable("User");
|
||||
$this->assertTrue($table instanceof UserTable);
|
||||
|
||||
}
|
||||
public function testCreate() {
|
||||
$email = $this->session->create("Email");
|
||||
$email = $this->connection->create("Email");
|
||||
$this->assertTrue($email instanceof Email);
|
||||
}
|
||||
public function testGetDBH() {
|
||||
$this->assertTrue($this->session->getDBH() instanceof PDO);
|
||||
$this->assertTrue($this->connection->getDBH() instanceof PDO);
|
||||
}
|
||||
public function testCount() {
|
||||
$this->assertTrue(is_integer(count($this->session)));
|
||||
$this->assertTrue(is_integer(count($this->connection)));
|
||||
}
|
||||
public function testGetIterator() {
|
||||
$this->assertTrue($this->session->getIterator() instanceof ArrayIterator);
|
||||
$this->assertTrue($this->connection->getIterator() instanceof ArrayIterator);
|
||||
}
|
||||
public function testGetState() {
|
||||
$this->assertEqual($this->session->getState(),Doctrine_Session::STATE_OPEN);
|
||||
$this->assertEqual(Doctrine_Lib::getSessionStateAsString($this->session->getState()), "open");
|
||||
$this->assertEqual($this->connection->getState(),Doctrine_Connection::STATE_OPEN);
|
||||
$this->assertEqual(Doctrine_Lib::getConnectionStateAsString($this->connection->getState()), "open");
|
||||
}
|
||||
public function testGetTables() {
|
||||
$this->assertTrue(is_array($this->session->getTables()));
|
||||
$this->assertTrue(is_array($this->connection->getTables()));
|
||||
}
|
||||
|
||||
public function testTransactions() {
|
||||
|
||||
$this->session->beginTransaction();
|
||||
$this->assertEqual($this->session->getState(),Doctrine_Session::STATE_ACTIVE);
|
||||
$this->session->commit();
|
||||
$this->assertEqual($this->session->getState(),Doctrine_Session::STATE_OPEN);
|
||||
$this->connection->beginTransaction();
|
||||
$this->assertEqual($this->connection->getState(),Doctrine_Connection::STATE_ACTIVE);
|
||||
$this->connection->commit();
|
||||
$this->assertEqual($this->connection->getState(),Doctrine_Connection::STATE_OPEN);
|
||||
|
||||
$this->session->beginTransaction();
|
||||
$this->connection->beginTransaction();
|
||||
|
||||
$user = $this->objTable->find(6);
|
||||
|
||||
$user->name = "Jack Daniels";
|
||||
$this->session->flush();
|
||||
$this->session->commit();
|
||||
$this->connection->flush();
|
||||
$this->connection->commit();
|
||||
|
||||
$user = $this->objTable->find(6);
|
||||
$this->assertEqual($user->name, "Jack Daniels");
|
||||
@ -330,27 +330,27 @@ class Doctrine_SessionTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testRollback() {
|
||||
$this->session->beginTransaction();
|
||||
$this->assertEqual($this->session->getTransactionLevel(),1);
|
||||
$this->assertEqual($this->session->getState(),Doctrine_Session::STATE_ACTIVE);
|
||||
$this->session->rollback();
|
||||
$this->assertEqual($this->session->getState(),Doctrine_Session::STATE_OPEN);
|
||||
$this->assertEqual($this->session->getTransactionLevel(),0);
|
||||
$this->connection->beginTransaction();
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),1);
|
||||
$this->assertEqual($this->connection->getState(),Doctrine_Connection::STATE_ACTIVE);
|
||||
$this->connection->rollback();
|
||||
$this->assertEqual($this->connection->getState(),Doctrine_Connection::STATE_OPEN);
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),0);
|
||||
}
|
||||
public function testNestedTransactions() {
|
||||
$this->assertEqual($this->session->getTransactionLevel(),0);
|
||||
$this->session->beginTransaction();
|
||||
$this->assertEqual($this->session->getTransactionLevel(),1);
|
||||
$this->assertEqual($this->session->getState(),Doctrine_Session::STATE_ACTIVE);
|
||||
$this->session->beginTransaction();
|
||||
$this->assertEqual($this->session->getState(),Doctrine_Session::STATE_BUSY);
|
||||
$this->assertEqual($this->session->getTransactionLevel(),2);
|
||||
$this->session->commit();
|
||||
$this->assertEqual($this->session->getState(),Doctrine_Session::STATE_ACTIVE);
|
||||
$this->assertEqual($this->session->getTransactionLevel(),1);
|
||||
$this->session->commit();
|
||||
$this->assertEqual($this->session->getState(),Doctrine_Session::STATE_OPEN);
|
||||
$this->assertEqual($this->session->getTransactionLevel(),0);
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),0);
|
||||
$this->connection->beginTransaction();
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),1);
|
||||
$this->assertEqual($this->connection->getState(),Doctrine_Connection::STATE_ACTIVE);
|
||||
$this->connection->beginTransaction();
|
||||
$this->assertEqual($this->connection->getState(),Doctrine_Connection::STATE_BUSY);
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),2);
|
||||
$this->connection->commit();
|
||||
$this->assertEqual($this->connection->getState(),Doctrine_Connection::STATE_ACTIVE);
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),1);
|
||||
$this->connection->commit();
|
||||
$this->assertEqual($this->connection->getState(),Doctrine_Connection::STATE_OPEN);
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),0);
|
||||
}
|
||||
}
|
||||
?>
|
@ -16,9 +16,9 @@ class Doctrine_CustomPrimaryKeyTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$c->save();
|
||||
$this->assertEqual($c->getID(), array("uid" => 1));
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
|
||||
$c = $this->session->getTable('CustomPK')->find(1);
|
||||
$c = $this->connection->getTable('CustomPK')->find(1);
|
||||
|
||||
$this->assertEqual($c->getID(), array("uid" => 1));
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ require_once("UnitTestCase.php");
|
||||
|
||||
class Doctrine_EventListenerTestCase extends Doctrine_UnitTestCase {
|
||||
public function testEvents() {
|
||||
$session = $this->manager->openSession(Doctrine_DB::getConnection());
|
||||
$connection = $this->manager->openConnection(Doctrine_DB::getConnection());
|
||||
$debug = $this->listener->getMessages();
|
||||
$last = end($debug);
|
||||
$this->assertTrue($last->getObject() instanceof Doctrine_Session);
|
||||
$this->assertTrue($last->getObject() instanceof Doctrine_Connection);
|
||||
$this->assertTrue($last->getCode() == Doctrine_EventListener_Debugger::EVENT_OPEN);
|
||||
}
|
||||
public function prepareData() { }
|
||||
|
@ -4,8 +4,8 @@ class Doctrine_ManagerTestCase extends Doctrine_UnitTestCase {
|
||||
public function testGetInstance() {
|
||||
$this->assertTrue(Doctrine_Manager::getInstance() instanceOf Doctrine_Manager);
|
||||
}
|
||||
public function testOpenSession() {
|
||||
$this->assertTrue($this->session instanceOf Doctrine_Session);
|
||||
public function testOpenConnection() {
|
||||
$this->assertTrue($this->connection instanceOf Doctrine_Connection);
|
||||
}
|
||||
public function testGetIterator() {
|
||||
$this->assertTrue($this->manager->getIterator() instanceof ArrayIterator);
|
||||
@ -13,11 +13,11 @@ class Doctrine_ManagerTestCase extends Doctrine_UnitTestCase {
|
||||
public function testCount() {
|
||||
$this->assertEqual(count($this->manager),1);
|
||||
}
|
||||
public function testGetCurrentSession() {
|
||||
$this->assertEqual($this->manager->getCurrentSession(), $this->session);
|
||||
public function testGetCurrentConnection() {
|
||||
$this->assertEqual($this->manager->getCurrentConnection(), $this->connection);
|
||||
}
|
||||
public function testGetSessions() {
|
||||
$this->assertEqual(count($this->manager->getSessions()),1);
|
||||
public function testGetConnections() {
|
||||
$this->assertEqual(count($this->manager->getConnections()),1);
|
||||
}
|
||||
public function prepareData() { }
|
||||
public function prepareTables() { }
|
||||
|
@ -15,7 +15,7 @@ class Doctrine_PessimisticLockingTestCase extends Doctrine_UnitTestCase
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->lockingManager = new Doctrine_Locking_Manager_Pessimistic($this->session);
|
||||
$this->lockingManager = new Doctrine_Locking_Manager_Pessimistic($this->connection);
|
||||
|
||||
// Create sample data to test on
|
||||
$entry1 = new Forum_Entry();
|
||||
@ -31,7 +31,7 @@ class Doctrine_PessimisticLockingTestCase extends Doctrine_UnitTestCase
|
||||
*/
|
||||
public function testLock()
|
||||
{
|
||||
$entries = $this->session->query("FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'");
|
||||
$entries = $this->connection->query("FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'");
|
||||
|
||||
// Test successful lock
|
||||
$gotLock = $this->lockingManager->getLock($entries[0], 'romanb');
|
||||
@ -51,7 +51,7 @@ class Doctrine_PessimisticLockingTestCase extends Doctrine_UnitTestCase
|
||||
*/
|
||||
public function testReleaseAgedLocks()
|
||||
{
|
||||
$entries = $this->session->query("FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'");
|
||||
$entries = $this->connection->query("FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'");
|
||||
$this->lockingManager->getLock($entries[0], 'romanb');
|
||||
$released = $this->lockingManager->releaseAgedLocks(-1); // age -1 seconds => release all
|
||||
$this->assertTrue($released);
|
||||
@ -64,4 +64,4 @@ class Doctrine_PessimisticLockingTestCase extends Doctrine_UnitTestCase
|
||||
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -8,7 +8,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
|
||||
parent::prepareTables();
|
||||
}
|
||||
public function testLimitWithOneToOneLeftJoin() {
|
||||
$q = new Doctrine_Query($this->session);
|
||||
$q = new Doctrine_Query($this->connection);
|
||||
$q->from('User(id).Email')->limit(5);
|
||||
|
||||
$users = $q->execute();
|
||||
@ -17,7 +17,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
}
|
||||
public function testLimitWithOneToOneInnerJoin() {
|
||||
$q = new Doctrine_Query($this->session);
|
||||
$q = new Doctrine_Query($this->connection);
|
||||
$q->from('User(id):Email')->limit(5);
|
||||
|
||||
$users = $q->execute();
|
||||
@ -51,7 +51,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testLimitWithOneToManyLeftJoinAndCondition() {
|
||||
$q = new Doctrine_Query($this->session);
|
||||
$q = new Doctrine_Query($this->connection);
|
||||
$q->from("User(name)")->where("User.Phonenumber.phonenumber LIKE '%123%'")->limit(5);
|
||||
$users = $q->execute();
|
||||
|
||||
@ -68,7 +68,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testLimitWithOneToManyLeftJoinAndOrderBy() {
|
||||
$q = new Doctrine_Query($this->session);
|
||||
$q = new Doctrine_Query($this->connection);
|
||||
$q->from("User(name)")->where("User.Phonenumber.phonenumber LIKE '%123%'")->orderby("User.Email.address")->limit(5);
|
||||
$users = $q->execute();
|
||||
|
||||
@ -147,11 +147,11 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
|
||||
$users = $q->execute(array('zYne'));
|
||||
|
||||
$this->assertEqual($users->count(), 1);
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
}
|
||||
|
||||
public function testLimitWithManyToManyColumnAggInheritanceLeftJoin() {
|
||||
$q = new Doctrine_Query($this->session);
|
||||
$q = new Doctrine_Query($this->connection);
|
||||
$q->from("User.Group")->limit(5);
|
||||
$users = $q->execute();
|
||||
|
||||
@ -169,7 +169,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$this->assertEqual($user->Group[0]->name, "Action Actors");
|
||||
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
|
||||
$this->assertEqual($user->Group[0]->name, "Action Actors");
|
||||
$this->assertEqual(count($user->Group), 3);
|
||||
@ -182,7 +182,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$this->assertEqual($users->count(), 3);
|
||||
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
$q = new Doctrine_Query();
|
||||
$q->from("User")->where("User.Group.id = ?")->orderby("User.id DESC");
|
||||
$users = $q->execute(array($user->Group[1]->id));
|
||||
@ -190,7 +190,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($users->count(), 3);
|
||||
}
|
||||
public function testLimitWithNormalManyToMany() {
|
||||
$coll = new Doctrine_Collection($this->session->getTable("Photo"));
|
||||
$coll = new Doctrine_Collection($this->connection->getTable("Photo"));
|
||||
$tag = new Tag();
|
||||
$tag->tag = "Some tag";
|
||||
$coll[0]->Tag[0] = $tag;
|
||||
@ -201,7 +201,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
|
||||
$coll[2]->name = "photo 3";
|
||||
$coll[3]->Tag[0]->tag = "Other tag";
|
||||
$coll[3]->name = "photo 4";
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
|
||||
$q = new Doctrine_Query();
|
||||
$q->from("Photo")->where("Photo.Tag.id = ?")->orderby("Photo.id DESC")->limit(100);
|
||||
|
@ -37,9 +37,9 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
public function testMultipleFetching() {
|
||||
$count = $this->dbh->count();
|
||||
$this->session->getTable('User')->clear();
|
||||
$this->session->getTable('Email')->clear();
|
||||
$this->session->getTable('Phonenumber')->clear();
|
||||
$this->connection->getTable('User')->clear();
|
||||
$this->connection->getTable('Email')->clear();
|
||||
$this->connection->getTable('Phonenumber')->clear();
|
||||
|
||||
$users = $this->query->from("User-l.Phonenumber-i, User-l:Email-i")->execute();
|
||||
$this->assertEqual(($count + 1),$this->dbh->count());
|
||||
@ -76,7 +76,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testConditionParser() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
|
||||
$query->from("User(id)")->where("User.name LIKE 'z%' || User.name LIKE 's%'");
|
||||
|
||||
@ -112,7 +112,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testSelfReferencing() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
|
||||
$category = new Forum_Category();
|
||||
|
||||
@ -124,8 +124,8 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$category->Subcategory[1]->Subcategory[0]->name = "Sub 2 Sub 1";
|
||||
$category->Subcategory[1]->Subcategory[1]->name = "Sub 2 Sub 2";
|
||||
|
||||
$this->session->flush();
|
||||
$this->session->clear();
|
||||
$this->connection->flush();
|
||||
$this->connection->clear();
|
||||
|
||||
$category = $category->getTable()->find($category->id);
|
||||
|
||||
@ -137,7 +137,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($category->Subcategory[1]->Subcategory[0]->name, "Sub 2 Sub 1");
|
||||
$this->assertEqual($category->Subcategory[1]->Subcategory[1]->name, "Sub 2 Sub 2");
|
||||
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
|
||||
|
||||
|
||||
@ -160,7 +160,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($category->Subcategory[1]->Subcategory[1]->name, "Sub 2 Sub 2");
|
||||
$this->assertEqual($count, count($this->dbh));
|
||||
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
$query->from("Forum_Category.Parent.Parent")->where("Forum_Category.name LIKE 'Sub%Sub%'");
|
||||
$coll = $query->execute();
|
||||
|
||||
@ -211,7 +211,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$this->assertEqual($count, count($this->dbh));
|
||||
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
|
||||
$query->from("Forum_Category.Subcategory.Subcategory")->where("Forum_Category.parent_category_id IS NULL");
|
||||
$coll = $query->execute();
|
||||
@ -251,9 +251,9 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testMultiComponentFetching2() {
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
|
||||
$query->from("User.Email, User.Phonenumber");
|
||||
|
||||
@ -269,10 +269,10 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testHaving() {
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
|
||||
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
$query->from('User-l.Phonenumber-l');
|
||||
$query->having("COUNT(User.Phonenumber.phonenumber) > 2");
|
||||
$query->groupby('User.id');
|
||||
@ -305,12 +305,12 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual(++$count, $this->dbh->count());
|
||||
$this->assertEqual($users[2]->Phonenumber->count(), 3);
|
||||
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
$query->from('User-l.Phonenumber-l');
|
||||
$query->having("COUNT(User.Phonenumber.phonenumber) > 2");
|
||||
$query->groupby('User.id');
|
||||
|
||||
$users = $this->session->query("FROM User-l.Phonenumber-l GROUP BY User.id HAVING COUNT(User.Phonenumber.phonenumber) > 2");
|
||||
$users = $this->connection->query("FROM User-l.Phonenumber-l GROUP BY User.id HAVING COUNT(User.Phonenumber.phonenumber) > 2");
|
||||
|
||||
$this->assertEqual($users->count(), 3);
|
||||
|
||||
@ -321,7 +321,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testManyToManyFetchingWithColumnAggregationInheritance() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
|
||||
$query->from('User-l:Group-l');
|
||||
|
||||
@ -350,7 +350,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($users[1]->type, 0);
|
||||
$this->assertEqual($users[2]->type, 0);
|
||||
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
|
||||
$users = $query->query("FROM User-b WHERE User.Group.name = 'Action Actors'");
|
||||
|
||||
@ -411,11 +411,11 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$task = new Task();
|
||||
$task->name = "T4";
|
||||
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
$query->from("Task.ResourceAlias.Type");
|
||||
$tasks = $query->execute();
|
||||
|
||||
@ -431,7 +431,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$this->assertEqual($tasks[1]->ResourceAlias->count(), 4);
|
||||
|
||||
$this->session->clear();
|
||||
$this->connection->clear();
|
||||
|
||||
$query->from("Task")->where("Task.ResourceAlias.Type.type = 'TY2' || Task.ResourceAlias.Type.type = 'TY1'");
|
||||
$tasks = $query->execute();
|
||||
@ -444,14 +444,14 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
|
||||
public function testManyToManyFetchingWithColonOperator() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
|
||||
$task = new Task();
|
||||
|
||||
// clear identity maps
|
||||
$this->session->getTable('Task')->clear();
|
||||
$this->session->getTable('Assignment')->clear();
|
||||
$this->session->getTable('Resource')->clear();
|
||||
$this->connection->getTable('Task')->clear();
|
||||
$this->connection->getTable('Assignment')->clear();
|
||||
$this->connection->getTable('Resource')->clear();
|
||||
|
||||
$tasks[1] = $task->getTable()->find(2);
|
||||
$this->assertEqual($tasks[1]->ResourceAlias[0]->name, "R3");
|
||||
@ -461,8 +461,8 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
// clear identity maps
|
||||
$task->getTable()->clear();
|
||||
$this->session->getTable('Assignment')->clear();
|
||||
$this->session->getTable('Resource')->clear();
|
||||
$this->connection->getTable('Assignment')->clear();
|
||||
$this->connection->getTable('Resource')->clear();
|
||||
|
||||
$query->from("Task-l:ResourceAlias-l");
|
||||
$tasks = $query->execute();
|
||||
@ -495,11 +495,11 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testManyToManyFetchingWithDotOperator() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
|
||||
$this->session->getTable('Task')->clear();
|
||||
$this->session->getTable('Assignment')->clear();
|
||||
$this->session->getTable('Resource')->clear();
|
||||
$this->connection->getTable('Task')->clear();
|
||||
$this->connection->getTable('Assignment')->clear();
|
||||
$this->connection->getTable('Resource')->clear();
|
||||
|
||||
$tasks = $query->query("FROM Task-l.ResourceAlias-l");
|
||||
$this->assertEqual($tasks->count(), 4);
|
||||
@ -536,7 +536,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testManyToManyFetchingWithDotOperatorAndLoadedIdentityMaps() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
|
||||
$tasks = $query->query("FROM Task-l.ResourceAlias-l");
|
||||
$this->assertEqual($tasks->count(), 4);
|
||||
@ -588,14 +588,14 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
|
||||
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
|
||||
// clear the identity maps
|
||||
|
||||
$entries[0]->Log_Status->getTable()->clear();
|
||||
$entries[0]->getTable()->clear();
|
||||
|
||||
$entries = $this->session->query("FROM Log_Entry-I.Log_Status-i");
|
||||
$entries = $this->connection->query("FROM Log_Entry-I.Log_Status-i");
|
||||
|
||||
$this->assertEqual($entries->count(), 2);
|
||||
|
||||
@ -620,7 +620,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$entries[0]->Log_Status->getTable()->clear();
|
||||
$entries[0]->getTable()->clear();
|
||||
|
||||
$entries = $this->session->query("FROM Log_Entry-I.Log_Status-i");
|
||||
$entries = $this->connection->query("FROM Log_Entry-I.Log_Status-i");
|
||||
$this->assertEqual($entries->count(), 2);
|
||||
|
||||
$this->assertTrue($entries[0]->Log_Status instanceof Log_Status);
|
||||
@ -641,11 +641,11 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$entry->amount = '123.123';
|
||||
$entry->ORM_TestItem->name = 'item 2';
|
||||
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
|
||||
$count = $this->dbh->count();
|
||||
|
||||
$entries = $this->session->query("FROM ORM_TestEntry-i.ORM_TestItem-i");
|
||||
$entries = $this->connection->query("FROM ORM_TestEntry-i.ORM_TestItem-i");
|
||||
|
||||
$this->assertEqual($entries->count(), 2);
|
||||
|
||||
@ -671,9 +671,9 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
public function testImmediateFetching() {
|
||||
$count = $this->dbh->count();
|
||||
$this->session->getTable('User')->clear();
|
||||
$this->session->getTable('Email')->clear();
|
||||
$this->session->getTable('Phonenumber')->clear();
|
||||
$this->connection->getTable('User')->clear();
|
||||
$this->connection->getTable('Email')->clear();
|
||||
$this->connection->getTable('Phonenumber')->clear();
|
||||
|
||||
$users = $this->query->from("User-i.Email-i")->execute();
|
||||
$this->assertEqual(($count + 1),$this->dbh->count());
|
||||
@ -694,7 +694,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
public function testLazyPropertyFetchingWithMultipleColumns() {
|
||||
|
||||
$q = new Doctrine_Query($this->session);
|
||||
$q = new Doctrine_Query($this->connection);
|
||||
$q->from("User-l(name, email_id)");
|
||||
$users = $q->execute();
|
||||
$this->assertEqual($users->count(), 8);
|
||||
@ -808,7 +808,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testValidLazyPropertyFetching() {
|
||||
$q = new Doctrine_Query($this->session);
|
||||
$q = new Doctrine_Query($this->connection);
|
||||
$q->from("User-l(name)");
|
||||
$users = $q->execute();
|
||||
$this->assertEqual($users->count(), 8);
|
||||
@ -839,7 +839,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testQueryWithComplexAliases() {
|
||||
$q = new Doctrine_Query($this->session);
|
||||
$q = new Doctrine_Query($this->connection);
|
||||
|
||||
$board = new Forum_Board();
|
||||
$table = $board->getTable();
|
||||
@ -869,7 +869,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($thread->Entries[0]->getState(), Doctrine_Record::STATE_TDIRTY);
|
||||
$this->assertTrue($thread->Entries[0] instanceof Forum_Entry);
|
||||
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
|
||||
$board->getTable()->clear();
|
||||
|
||||
@ -887,8 +887,8 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$coll = $q->execute();
|
||||
$this->assertEqual($coll->count(), 1);
|
||||
|
||||
$table = $this->session->getTable("Forum_Board")->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_LAZY);
|
||||
$table = $this->session->getTable("Forum_Thread")->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_LAZY);
|
||||
$table = $this->connection->getTable("Forum_Board")->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_LAZY);
|
||||
$table = $this->connection->getTable("Forum_Thread")->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_LAZY);
|
||||
$q->from("Forum_Board.Threads");
|
||||
|
||||
$this->assertEqual($q->getQuery(), "SELECT forum_board.id AS forum_board__id, forum_thread.id AS forum_thread__id FROM forum_board LEFT JOIN forum_thread ON forum_board.id = forum_thread.board_id");
|
||||
@ -900,7 +900,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$q->from("Forum_Board-l.Threads-l");
|
||||
$this->assertEqual($q->getQuery(), "SELECT forum_board.id AS forum_board__id, forum_thread.id AS forum_thread__id FROM forum_board LEFT JOIN forum_thread ON forum_board.id = forum_thread.board_id");
|
||||
|
||||
//$this->session->clear();
|
||||
//$this->connection->clear();
|
||||
|
||||
$q->from("Forum_Board-l.Threads-l.Entries-l");
|
||||
$this->assertEqual($q->getQuery(), "SELECT forum_board.id AS forum_board__id, forum_thread.id AS forum_thread__id, forum_entry.id AS forum_entry__id FROM forum_board LEFT JOIN forum_thread ON forum_board.id = forum_thread.board_id LEFT JOIN forum_entry ON forum_thread.id = forum_entry.thread_id");
|
||||
@ -922,7 +922,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testQueryWithAliases() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
|
||||
$task = new Task();
|
||||
$task->name = "Task 1";
|
||||
@ -939,7 +939,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testQueryArgs() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
$query = $query->from("User-l");
|
||||
|
||||
$this->assertTrue($query instanceof Doctrine_Query);
|
||||
@ -991,23 +991,23 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testLimit() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
$coll = $query->query("FROM User(id) LIMIT 3");
|
||||
$this->assertEqual($query->limit, 3);
|
||||
$this->assertEqual($coll->count(), 3);
|
||||
}
|
||||
public function testOffset() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
$coll = $query->query("FROM User LIMIT 3 OFFSET 3");
|
||||
$this->assertEqual($query->offset, 3);
|
||||
$this->assertEqual($coll->count(), 3);
|
||||
}
|
||||
public function testPreparedQuery() {
|
||||
$coll = $this->session->query("FROM User WHERE User.name = :name", array(":name" => "zYne"));
|
||||
$coll = $this->connection->query("FROM User WHERE User.name = :name", array(":name" => "zYne"));
|
||||
$this->assertEqual($coll->count(), 1);
|
||||
}
|
||||
public function testOrderBy() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
$query->from("User-b")->orderby("User.name ASC, User.Email.address");
|
||||
$users = $query->execute();
|
||||
|
||||
@ -1017,7 +1017,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertTrue($users[0]->name == "Arnold Schwarzenegger");
|
||||
}
|
||||
public function testBatchFetching() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
$users = $query->query("FROM User-b");
|
||||
$this->assertEqual(trim($query->getQuery()),
|
||||
"SELECT entity.id AS entity__id FROM entity WHERE (entity.type = 0)");
|
||||
@ -1026,7 +1026,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertTrue($users instanceof Doctrine_Collection_Batch);
|
||||
}
|
||||
public function testLazyFetching() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
$users = $query->query("FROM User-l");
|
||||
$this->assertEqual(trim($query->getQuery()),
|
||||
"SELECT entity.id AS entity__id FROM entity WHERE (entity.type = 0)");
|
||||
@ -1038,14 +1038,14 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
public function testAlbumManager() {
|
||||
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
|
||||
$this->graph = $query;
|
||||
|
||||
$user = $this->objTable->find(5);
|
||||
|
||||
|
||||
$album = $this->session->create("Album");
|
||||
$album = $this->connection->create("Album");
|
||||
$album->Song[0];
|
||||
|
||||
$user->Album[0]->name = "Damage Done";
|
||||
@ -1077,7 +1077,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
function testQuery() {
|
||||
// DYNAMIC COLLECTION EXPANDING
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
|
||||
$user = $this->objTable->find(5);
|
||||
$user->Group[1]->name = "Tough guys inc.";
|
||||
@ -1100,14 +1100,14 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
//$this->assertEqual($users[0]->Group[2]->name, "Terminators");
|
||||
//$this->assertEqual(count($users[0]->Group), 3);
|
||||
|
||||
$this->session->getTable("User")->clear();
|
||||
$this->session->getTable("Phonenumber")->clear();
|
||||
$this->connection->getTable("User")->clear();
|
||||
$this->connection->getTable("Phonenumber")->clear();
|
||||
|
||||
$users = $query->query("FROM User-b.Phonenumber-l WHERE User.Phonenumber.phonenumber LIKE '%123%'");
|
||||
$this->assertEqual(trim($query->getQuery()),
|
||||
"SELECT entity.id AS entity__id, phonenumber.id AS phonenumber__id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE phonenumber.phonenumber LIKE '%123%' AND (entity.type = 0)");
|
||||
|
||||
$count = $this->session->getDBH()->count();
|
||||
$count = $this->connection->getDBH()->count();
|
||||
|
||||
$users[1]->Phonenumber[0]->phonenumber;
|
||||
$users[1]->Phonenumber[1]->phonenumber;
|
||||
@ -1115,7 +1115,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$users[1]->Phonenumber[2]->phonenumber;
|
||||
$this->assertEqual($users[1]->Phonenumber[1]->getState(),Doctrine_Record::STATE_CLEAN);
|
||||
$count2 = $this->session->getDBH()->count();
|
||||
$count2 = $this->connection->getDBH()->count();
|
||||
$this->assertEqual($count + 4,$count2);
|
||||
|
||||
|
||||
@ -1133,11 +1133,11 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual(trim($query->getQuery()),
|
||||
"SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id FROM entity WHERE (entity.type = 0)");
|
||||
|
||||
$count = $this->session->getDBH()->count();
|
||||
$count = $this->connection->getDBH()->count();
|
||||
$this->assertEqual($users[0]->name, "zYne");
|
||||
|
||||
$this->assertTrue($users instanceof Doctrine_Collection_Immediate);
|
||||
$count2 = $this->session->getDBH()->count();
|
||||
$count2 = $this->connection->getDBH()->count();
|
||||
|
||||
|
||||
|
||||
@ -1154,9 +1154,9 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
// EXPECTED THAT ONE NEW QUERY IS NEEDED TO GET THE FIRST USER's PHONENUMBER
|
||||
|
||||
$count = $this->session->getDBH()->count();
|
||||
$count = $this->connection->getDBH()->count();
|
||||
$users[0]->Phonenumber[0]->phonenumber;
|
||||
$count2 = $this->session->getDBH()->count();
|
||||
$count2 = $this->connection->getDBH()->count();
|
||||
$this->assertEqual($count + 1,$count2);
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
|
||||
public function testQueryParser() {
|
||||
$sql = "SELECT {p.*} FROM photos p";
|
||||
$query = new Doctrine_RawSql($this->session);
|
||||
$query = new Doctrine_RawSql($this->connection);
|
||||
$query->parseQuery($sql);
|
||||
|
||||
$this->assertEqual($query->from, array('photos p'));
|
||||
@ -19,7 +19,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
|
||||
public function testAsteriskOperator() {
|
||||
// Selecting with *
|
||||
|
||||
$query = new Doctrine_RawSql($this->session);
|
||||
$query = new Doctrine_RawSql($this->connection);
|
||||
$query->parseQuery("SELECT {entity.*} FROM entity");
|
||||
$fields = $query->getFields();
|
||||
|
||||
@ -33,8 +33,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testLazyPropertyLoading() {
|
||||
$query = new Doctrine_RawSql($this->session);
|
||||
$this->session->clear();
|
||||
$query = new Doctrine_RawSql($this->connection);
|
||||
$this->connection->clear();
|
||||
|
||||
// selecting proxy objects (lazy property loading)
|
||||
|
||||
@ -53,7 +53,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testSmartMapping() {
|
||||
$query = new Doctrine_RawSql($this->session);
|
||||
$query = new Doctrine_RawSql($this->connection);
|
||||
// smart component mapping (no need for additional addComponent call
|
||||
|
||||
$query->parseQuery("SELECT {entity.name}, {entity.id} FROM entity");
|
||||
@ -70,7 +70,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testMultipleComponents() {
|
||||
$query = new Doctrine_RawSql($this->session);
|
||||
$query = new Doctrine_RawSql($this->connection);
|
||||
// multi component fetching
|
||||
|
||||
$query->parseQuery("SELECT {entity.name}, {entity.id}, {phonenumber.*} FROM entity LEFT JOIN phonenumber ON phonenumber.entity_id = entity.id");
|
||||
@ -92,7 +92,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
|
||||
public function testPrimaryKeySelectForcing() {
|
||||
// forcing the select of primary key fields
|
||||
|
||||
$query = new Doctrine_RawSql($this->session);
|
||||
$query = new Doctrine_RawSql($this->connection);
|
||||
|
||||
$query->parseQuery("SELECT {entity.name} FROM entity");
|
||||
|
||||
@ -104,7 +104,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertTrue(is_numeric($coll[7]->id));
|
||||
}
|
||||
public function testMethodOverloading() {
|
||||
$query = new Doctrine_RawSql($this->session);
|
||||
$query = new Doctrine_RawSql($this->connection);
|
||||
$query->select('{entity.name}')->from('entity');
|
||||
$query->addComponent("entity", "User");
|
||||
$coll = $query->execute();
|
||||
@ -117,7 +117,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
|
||||
public function testColumnAggregationInheritance() {
|
||||
// forcing the select of primary key fields
|
||||
|
||||
$query = new Doctrine_RawSql($this->session);
|
||||
$query = new Doctrine_RawSql($this->connection);
|
||||
|
||||
$query->parseQuery("SELECT {entity.name} FROM entity");
|
||||
$query->addComponent("entity", "User");
|
||||
|
@ -79,13 +79,13 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($e->Entity[0]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertEqual($e->Entity[1]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
|
||||
$coll = $this->session->query("FROM Entity WHERE Entity.name = 'Friend 1'");
|
||||
$coll = $this->connection->query("FROM Entity WHERE Entity.name = 'Friend 1'");
|
||||
$this->assertEqual($coll->count(), 1);
|
||||
$this->assertEqual($coll[0]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
|
||||
$this->assertEqual($coll[0]->name, "Friend 1");
|
||||
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
|
||||
$query->from("Entity.Entity")->where("Entity.Entity.name = 'Friend 1 1'");
|
||||
|
||||
@ -115,7 +115,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testSerialize() {
|
||||
$user = $this->session->getTable("User")->find(4);
|
||||
$user = $this->connection->getTable("User")->find(4);
|
||||
$str = serialize($user);
|
||||
$user2 = unserialize($str);
|
||||
|
||||
@ -191,26 +191,26 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
$record->entity1 = 2;
|
||||
$record->save();
|
||||
|
||||
$coll = $this->session->query("FROM EntityReference-b");
|
||||
$coll = $this->connection->query("FROM EntityReference-b");
|
||||
$this->assertTrue($coll[0] instanceof EntityReference);
|
||||
$this->assertEqual($coll[0]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertTrue($coll[1] instanceof EntityReference);
|
||||
$this->assertEqual($coll[1]->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
|
||||
$coll = $this->session->query("FROM EntityReference-b WHERE EntityReference.entity2 = 5");
|
||||
$coll = $this->connection->query("FROM EntityReference-b WHERE EntityReference.entity2 = 5");
|
||||
$this->assertEqual($coll->count(), 1);
|
||||
}
|
||||
|
||||
|
||||
public function testManyToManyTreeStructure() {
|
||||
|
||||
$task = $this->session->create("Task");
|
||||
$task = $this->connection->create("Task");
|
||||
$this->assertEqual($task->getTable()->getAlias("Resource"), "ResourceAlias");
|
||||
|
||||
$task->name = "Task 1";
|
||||
$task->ResourceAlias[0]->name = "Resource 1";
|
||||
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
|
||||
$this->assertTrue($task->ResourceAlias[0] instanceof Resource);
|
||||
$this->assertEqual($task->ResourceAlias[0]->name, "Resource 1");
|
||||
@ -234,7 +234,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($task->ResourceAlias->count(), 1);
|
||||
$this->assertEqual($task->Subtask[0]->name, "Subtask 1");
|
||||
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
|
||||
$task = $task->getTable()->find($task->getID());
|
||||
|
||||
@ -274,7 +274,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
$account->amount = 2000;
|
||||
$this->assertEqual($account->getTable()->getColumnNames(), array("id","entity_id","amount"));
|
||||
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
$this->assertEqual($user->getState(), Doctrine_Record::STATE_CLEAN);
|
||||
$this->assertTrue($account instanceof Account);
|
||||
|
||||
@ -316,9 +316,9 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testNewOperator() {
|
||||
$table = $this->session->getTable("User");
|
||||
$table = $this->connection->getTable("User");
|
||||
|
||||
$this->assertEqual($this->session->getTable("User")->getData(), array());
|
||||
$this->assertEqual($this->connection->getTable("User")->getData(), array());
|
||||
$user = new User();
|
||||
$this->assertEqual(Doctrine_Lib::getRecordStateAsString($user->getState()), Doctrine_Lib::getRecordStateAsString(Doctrine_Record::STATE_TCLEAN));
|
||||
$user->name = "John Locke";
|
||||
@ -357,8 +357,8 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
|
||||
|
||||
$this->session->flush();
|
||||
$elements = $this->session->query("FROM Element-l");
|
||||
$this->connection->flush();
|
||||
$elements = $this->connection->query("FROM Element-l");
|
||||
$this->assertEqual($elements->count(), 5);
|
||||
|
||||
$e = $e->getTable()->find(1);
|
||||
@ -422,7 +422,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$e->save();
|
||||
|
||||
$coll = $this->session->query("FROM Error-I");
|
||||
$coll = $this->connection->query("FROM Error-I");
|
||||
$e = $coll[0];
|
||||
|
||||
|
||||
@ -467,7 +467,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$debug = $this->listener->getMessages();
|
||||
$p = array_pop($debug);
|
||||
$this->assertTrue($p->getObject() instanceof Doctrine_Session);
|
||||
$this->assertTrue($p->getObject() instanceof Doctrine_Connection);
|
||||
$this->assertTrue($p->getCode() == Doctrine_EventListener_Debugger::EVENT_COMMIT);
|
||||
|
||||
$user->delete();
|
||||
@ -475,7 +475,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testUpdate() {
|
||||
$user = $this->session->getTable("User")->find(4);
|
||||
$user = $this->connection->getTable("User")->find(4);
|
||||
$user->set("name","Jack Daniels",true);
|
||||
|
||||
|
||||
@ -487,7 +487,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$debug = $this->listener->getMessages();
|
||||
$p = array_pop($debug);
|
||||
$this->assertTrue($p->getObject() instanceof Doctrine_Session);
|
||||
$this->assertTrue($p->getObject() instanceof Doctrine_Connection);
|
||||
$this->assertTrue($p->getCode() == Doctrine_EventListener_Debugger::EVENT_COMMIT);
|
||||
|
||||
$p = array_pop($debug);
|
||||
@ -501,7 +501,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
}
|
||||
public function testCopy() {
|
||||
$user = $this->session->getTable("User")->find(4);
|
||||
$user = $this->connection->getTable("User")->find(4);
|
||||
$new = $user->copy();
|
||||
$this->assertTrue($new instanceof Doctrine_Record);
|
||||
$this->assertTrue($new->getState() == Doctrine_Record::STATE_TDIRTY);
|
||||
@ -511,7 +511,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$user = $this->objTable->find(5);
|
||||
|
||||
$pf = $this->session->getTable("Phonenumber");
|
||||
$pf = $this->connection->getTable("Phonenumber");
|
||||
|
||||
$this->assertTrue($user->Phonenumber instanceof Doctrine_Collection);
|
||||
$this->assertEqual($user->Phonenumber->count(), 3);
|
||||
@ -615,7 +615,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
// REPLACING ONE-TO-ONE REFERENCES
|
||||
|
||||
$email = $this->session->create("Email");
|
||||
$email = $this->connection->create("Email");
|
||||
$email->address = "absolutist@nottodrink.com";
|
||||
$user->Email = $email;
|
||||
|
||||
@ -628,7 +628,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertTrue($user->Email instanceof Email);
|
||||
$this->assertEqual($user->Email->address, "absolutist@nottodrink.com");
|
||||
|
||||
$emails = $this->session->query("FROM Email WHERE Email.id = $id");
|
||||
$emails = $this->connection->query("FROM Email WHERE Email.id = $id");
|
||||
//$this->assertEqual(count($emails),0);
|
||||
|
||||
}
|
||||
@ -643,7 +643,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
public function testSaveAssociations() {
|
||||
$user = $this->objTable->find(5);
|
||||
|
||||
$gf = $this->session->getTable("Group");
|
||||
$gf = $this->connection->getTable("Group");
|
||||
|
||||
$this->assertTrue($user->Group instanceof Doctrine_Collection);
|
||||
|
||||
@ -743,13 +743,13 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testCount() {
|
||||
$user = $this->session->getTable("User")->find(4);
|
||||
$user = $this->connection->getTable("User")->find(4);
|
||||
|
||||
$this->assertTrue(is_integer($user->count()));
|
||||
}
|
||||
|
||||
public function testGetReference() {
|
||||
$user = $this->session->getTable("User")->find(4);
|
||||
$user = $this->connection->getTable("User")->find(4);
|
||||
|
||||
$this->assertTrue($user->Email instanceof Doctrine_Record);
|
||||
$this->assertTrue($user->Phonenumber instanceof Doctrine_Collection);
|
||||
@ -758,7 +758,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertTrue($user->Phonenumber->count() == 1);
|
||||
}
|
||||
public function testGetIterator() {
|
||||
$user = $this->session->getTable("User")->find(4);
|
||||
$user = $this->connection->getTable("User")->find(4);
|
||||
$this->assertTrue($user->getIterator() instanceof ArrayIterator);
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,11 @@
|
||||
require_once("UnitTestCase.php");
|
||||
class Doctrine_TableTestCase extends Doctrine_UnitTestCase {
|
||||
public function testBind() {
|
||||
$table = $this->session->getTable("User");
|
||||
$table = $this->connection->getTable("User");
|
||||
}
|
||||
|
||||
public function testGetIdentifier() {
|
||||
$table = $this->session->getTable("User");
|
||||
$table = $this->connection->getTable("User");
|
||||
}
|
||||
public function testGetForeignKey() {
|
||||
$fk = $this->objTable->getForeignKey("Group");
|
||||
@ -39,8 +39,8 @@ class Doctrine_TableTestCase extends Doctrine_UnitTestCase {
|
||||
public function testGetTableName() {
|
||||
$this->assertTrue($this->objTable->getTableName() == "entity");
|
||||
}
|
||||
public function testGetSession() {
|
||||
$this->assertTrue($this->objTable->getSession() instanceof Doctrine_Session);
|
||||
public function testGetConnection() {
|
||||
$this->assertTrue($this->objTable->getConnection() instanceof Doctrine_Connection);
|
||||
}
|
||||
public function testGetData() {
|
||||
$this->assertTrue($this->objTable->getData() == array());
|
||||
|
@ -19,7 +19,7 @@ require_once("simpletest/reporter.php");
|
||||
|
||||
class Doctrine_UnitTestCase extends UnitTestCase {
|
||||
protected $manager;
|
||||
protected $session;
|
||||
protected $connection;
|
||||
protected $objTable;
|
||||
protected $new;
|
||||
protected $old;
|
||||
@ -63,24 +63,24 @@ class Doctrine_UnitTestCase extends UnitTestCase {
|
||||
|
||||
|
||||
if($this->manager->count() > 0) {
|
||||
$this->session = $this->manager->getSession(0);
|
||||
$this->session->evictTables();
|
||||
$this->dbh = $this->session->getDBH();
|
||||
$this->connection = $this->manager->getConnection(0);
|
||||
$this->connection->evictTables();
|
||||
$this->dbh = $this->connection->getDBH();
|
||||
$this->listener = $this->manager->getAttribute(Doctrine::ATTR_LISTENER);
|
||||
|
||||
} else {
|
||||
//$this->dbh = Doctrine_DB::getConnection();
|
||||
$this->dbh = Doctrine_DB::getConn("sqlite::memory:");
|
||||
//$this->dbh = new PDO("sqlite::memory:");
|
||||
$this->session = $this->manager->openSession($this->dbh);
|
||||
$this->connection = $this->manager->openConnection($this->dbh);
|
||||
$this->listener = new Doctrine_EventListener_Debugger();
|
||||
$this->manager->setAttribute(Doctrine::ATTR_LISTENER, $this->listener);
|
||||
}
|
||||
$this->query = new Doctrine_Query($this->session);
|
||||
$this->query = new Doctrine_Query($this->connection);
|
||||
$this->prepareTables();
|
||||
$this->prepareData();
|
||||
|
||||
$this->valueHolder = new Doctrine_ValueHolder($this->session->getTable('User'));
|
||||
$this->valueHolder = new Doctrine_ValueHolder($this->connection->getTable('User'));
|
||||
}
|
||||
public function prepareTables() {
|
||||
foreach($this->tables as $name) {
|
||||
@ -94,15 +94,15 @@ class Doctrine_UnitTestCase extends UnitTestCase {
|
||||
|
||||
foreach($this->tables as $name) {
|
||||
$name = ucwords($name);
|
||||
$table = $this->session->getTable($name);
|
||||
$table = $this->connection->getTable($name);
|
||||
$table->getCache()->deleteAll();
|
||||
$table->clear();
|
||||
}
|
||||
|
||||
$this->objTable = $this->session->getTable("User");
|
||||
$this->objTable = $this->connection->getTable("User");
|
||||
}
|
||||
public function prepareData() {
|
||||
$groups = new Doctrine_Collection($this->session->getTable("Group"));
|
||||
$groups = new Doctrine_Collection($this->connection->getTable("Group"));
|
||||
|
||||
$groups[0]->name = "Drama Actors";
|
||||
|
||||
@ -113,7 +113,7 @@ class Doctrine_UnitTestCase extends UnitTestCase {
|
||||
$groups[2]["Phonenumber"][0]->phonenumber = "123 123";
|
||||
$groups->save();
|
||||
|
||||
$users = new Doctrine_Collection($this->session->getTable("User"));
|
||||
$users = new Doctrine_Collection($this->connection->getTable("User"));
|
||||
|
||||
|
||||
$users[0]->name = "zYne";
|
||||
@ -156,14 +156,14 @@ class Doctrine_UnitTestCase extends UnitTestCase {
|
||||
$users[7]->Phonenumber[0]->phonenumber = "111 567 333";
|
||||
|
||||
$this->users = $users;
|
||||
$this->session->flush();
|
||||
$this->connection->flush();
|
||||
}
|
||||
public function getSession() {
|
||||
return $this->session;
|
||||
public function getConnection() {
|
||||
return $this->connection;
|
||||
}
|
||||
public function clearCache() {
|
||||
foreach($this->tables as $name) {
|
||||
$table = $this->session->getTable($name);
|
||||
$table = $this->connection->getTable($name);
|
||||
$table->getCache()->deleteAll();
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
public function testValidate() {
|
||||
$user = $this->session->getTable("User")->find(4);
|
||||
$user = $this->connection->getTable("User")->find(4);
|
||||
|
||||
$set = array("password" => "this is an example of too long password",
|
||||
"loginname" => "this is an example of too long loginname",
|
||||
@ -129,7 +129,7 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$validator = new Doctrine_Validator_Email();
|
||||
|
||||
$email = $this->session->create("Email");
|
||||
$email = $this->connection->create("Email");
|
||||
$this->assertFalse($validator->validate($email,"address","example@example",null));
|
||||
$this->assertFalse($validator->validate($email,"address","example@@example",null));
|
||||
$this->assertFalse($validator->validate($email,"address","example@example.",null));
|
||||
@ -141,7 +141,7 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
public function testSave() {
|
||||
$this->manager->setAttribute(Doctrine::ATTR_VLD, true);
|
||||
$user = $this->session->getTable("User")->find(4);
|
||||
$user = $this->connection->getTable("User")->find(4);
|
||||
try {
|
||||
$user->name = "this is an example of too long name not very good example but an example nevertheless";
|
||||
$user->save();
|
||||
@ -150,7 +150,7 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
|
||||
try {
|
||||
$user = $this->session->create("User");
|
||||
$user = $this->connection->create("User");
|
||||
$user->Email->address = "jackdaniels@drinkmore.info...";
|
||||
$user->name = "this is an example of too long user name not very good example but an example nevertheles";
|
||||
$user->save();
|
||||
|
@ -17,7 +17,7 @@ class Doctrine_ValueHolder_TestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($this->valueHolder->get('key'), 'second');
|
||||
}
|
||||
public function testSimpleQuery() {
|
||||
$q = new Doctrine_Query($this->session);
|
||||
$q = new Doctrine_Query($this->connection);
|
||||
$q->from("User");
|
||||
$users = $q->execute(array(), Doctrine::FETCH_VHOLDER);
|
||||
$this->assertEqual($users->count(), 8);
|
||||
@ -25,7 +25,7 @@ class Doctrine_ValueHolder_TestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
}
|
||||
public function testQueryWithOneToManyRelation() {
|
||||
$q = new Doctrine_Query($this->session);
|
||||
$q = new Doctrine_Query($this->connection);
|
||||
$q->from("User.Phonenumber");
|
||||
$users = $q->execute(array(), Doctrine::FETCH_VHOLDER);
|
||||
$this->assertEqual($users->count(), 8);
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
class Doctrine_ViewTestCase extends Doctrine_UnitTestCase {
|
||||
public function testCreateView() {
|
||||
$query = new Doctrine_Query($this->session);
|
||||
$query = new Doctrine_Query($this->connection);
|
||||
$query->from('User');
|
||||
|
||||
$view = new Doctrine_View($query, 'MyView');
|
||||
@ -38,6 +38,6 @@ class Doctrine_ViewTestCase extends Doctrine_UnitTestCase {
|
||||
}
|
||||
public function testConstructor() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -47,8 +47,8 @@ class Address extends Doctrine_Record {
|
||||
}
|
||||
}
|
||||
|
||||
// grouptable doesn't extend Doctrine_Table -> Doctrine_Session
|
||||
// won't initialize grouptable when Doctrine_Session->getTable("Group") is called
|
||||
// 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 {
|
||||
|
@ -3,7 +3,7 @@ ob_start();
|
||||
|
||||
require_once("ConfigurableTestCase.php");
|
||||
require_once("ManagerTestCase.php");
|
||||
require_once("SessionTestCase.php");
|
||||
require_once("ConnectionTestCase.php");
|
||||
require_once("TableTestCase.php");
|
||||
require_once("EventListenerTestCase.php");
|
||||
require_once("BatchIteratorTestCase.php");
|
||||
@ -31,7 +31,7 @@ $test = new GroupTest("Doctrine Framework Unit Tests");
|
||||
|
||||
$test->addTestCase(new Doctrine_RecordTestCase());
|
||||
|
||||
$test->addTestCase(new Doctrine_SessionTestCase());
|
||||
$test->addTestCase(new Doctrine_ConnectionTestCase());
|
||||
|
||||
$test->addTestCase(new Doctrine_TableTestCase());
|
||||
|
||||
@ -76,7 +76,7 @@ $test->addTestCase(new Doctrine_Query_Limit_TestCase());
|
||||
print "<pre>";
|
||||
$test->run(new HtmlReporter());
|
||||
/**
|
||||
$cache = Doctrine_Manager::getInstance()->getCurrentSession()->getCacheHandler();
|
||||
$cache = Doctrine_Manager::getInstance()->getCurrentConnection()->getCacheHandler();
|
||||
if(isset($cache)) {
|
||||
$a = $cache->getQueries();
|
||||
print "Executed cache queries: ".count($a)."\n";
|
||||
@ -88,7 +88,7 @@ if(isset($cache)) {
|
||||
}
|
||||
*/
|
||||
|
||||
$dbh = Doctrine_Manager::getInstance()->getCurrentSession()->getDBH();
|
||||
$dbh = Doctrine_Manager::getInstance()->getCurrentConnection()->getDBH();
|
||||
$a = $dbh->getQueries();
|
||||
|
||||
print "Executed queries: ".count($a)."\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user