Commit a0958f7d authored by zYne's avatar zYne

--no commit message

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