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 {
public function prepareData() { }
public function prepareTables() {
$this->tables = array("Entity", "User");
parent::prepareTables();
parent::prepareTables();
}
public function testOffsetMethods() {
$user = new User();
......@@ -14,7 +14,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
$user->save();
$user = $this->session->getTable("User")->find($user->getID());
$user = $this->connection->getTable("User")->find($user->getID());
$this->assertEqual($user->name,"Jack");
$user["name"] = "Jack";
......@@ -32,7 +32,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
$user->save();
$user = $this->session->getTable("User")->find($user->getID());
$user = $this->connection->getTable("User")->find($user->getID());
$this->assertEqual($user->name,"Jack");
$user->name = "Jack";
......@@ -49,7 +49,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
$user->save();
$user = $this->session->getTable("User")->find($user->getID());
$user = $this->connection->getTable("User")->find($user->getID());
$this->assertEqual($user->get("name"),"Jack");
......
......@@ -9,7 +9,7 @@ class Doctrine_BatchIteratorTestCase extends Doctrine_UnitTestCase {
}
public function testIterator() {
$graph = new Doctrine_Query($this->session);
$graph = new Doctrine_Query($this->connection);
$entities = $graph->query("FROM Entity");
$i = 0;
foreach($entities as $entity) {
......
......@@ -5,12 +5,12 @@ class Doctrine_Cache_Query_SqliteTestCase extends Doctrine_UnitTestCase {
public function setUp() {
parent::setUp();
$this->manager->setAttribute(Doctrine::ATTR_CACHE,Doctrine::CACHE_NONE);
$dir = $this->session->getAttribute(Doctrine::ATTR_CACHE_DIR);
$dir = $this->connection->getAttribute(Doctrine::ATTR_CACHE_DIR);
if(file_exists($dir.DIRECTORY_SEPARATOR."stats.cache"))
unlink($dir.DIRECTORY_SEPARATOR."stats.cache");
$this->cache = new Doctrine_Cache_Query_Sqlite($this->session);
$this->cache = new Doctrine_Cache_Query_Sqlite($this->connection);
$this->cache->deleteAll();
}
public function testStore() {
......
......@@ -5,7 +5,7 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase {
public function setUp() {
parent::setUp();
$this->manager->setAttribute(Doctrine::ATTR_CACHE,Doctrine::CACHE_NONE);
$dir = $this->session->getAttribute(Doctrine::ATTR_CACHE_DIR);
$dir = $this->connection->getAttribute(Doctrine::ATTR_CACHE_DIR);
if(file_exists($dir.DIRECTORY_SEPARATOR."stats.cache"))
unlink($dir.DIRECTORY_SEPARATOR."stats.cache");
......
......@@ -2,7 +2,7 @@
class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
public function testExpand() {
$users = $this->session->query("FROM User-o");
$users = $this->connection->query("FROM User-o");
$this->assertTrue($users instanceof Doctrine_Collection_Offset);
$this->assertEqual(count($users), 5);
......@@ -11,9 +11,9 @@ class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($users[5]->getState(), Doctrine_Record::STATE_CLEAN);
$users[5];
$this->session->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
$users = $this->session->query("FROM User-o");
$users = $this->connection->query("FROM User-o");
$this->assertEqual(count($users), 3);
$this->assertEqual($users[0]->getState(), Doctrine_Record::STATE_CLEAN);
$this->assertEqual($users[1]->getState(), Doctrine_Record::STATE_CLEAN);
......@@ -39,8 +39,8 @@ class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($users[5]->getState(), Doctrine_Record::STATE_CLEAN);
$this->session->setAttribute(Doctrine::ATTR_COLL_LIMIT, 1);
$users = $this->session->query("FROM User-b, User.Phonenumber-o WHERE User.".$this->objTable->getIdentifier()." = 5");
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 1);
$users = $this->connection->query("FROM User-b, User.Phonenumber-o WHERE User.".$this->objTable->getIdentifier()." = 5");
$this->assertEqual(count($users), 1);
......@@ -54,8 +54,8 @@ class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
}
public function testGetIterator() {
$this->session->setAttribute(Doctrine::ATTR_COLL_LIMIT, 4);
$coll = $this->session->query("FROM User-o");
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 4);
$coll = $this->connection->query("FROM User-o");
foreach($coll as $user) {
}
......@@ -63,9 +63,9 @@ class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($coll[3]->getState(), Doctrine_Record::STATE_CLEAN);
$this->assertEqual($coll[6]->getState(), Doctrine_Record::STATE_CLEAN);
$this->session->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
$this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
$coll = $this->session->query("FROM User-o");
$coll = $this->connection->query("FROM User-o");
foreach($coll as $user) {
}
......
......@@ -16,7 +16,7 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
}
public function testLoadRelatedForAssociation() {
$coll = $this->session->query("FROM User");
$coll = $this->connection->query("FROM User");
$this->assertEqual($coll->count(), 8);
......@@ -34,9 +34,9 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$coll->save();
$this->session->clear();
$this->connection->clear();
$coll = $this->session->query("FROM User");
$coll = $this->connection->query("FROM User");
$this->assertEqual($coll->count(), 8);
$this->assertEqual($coll[0]->Group->count(), 2);
......@@ -44,9 +44,9 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($coll[2]->Group->count(), 3);
$this->assertEqual($coll[5]->Group->count(), 3);
$this->session->clear();
$this->connection->clear();
$coll = $this->session->query("FROM User");
$coll = $this->connection->query("FROM User");
$this->assertEqual($coll->count(), 8);
......@@ -67,10 +67,10 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$this->assertEqual(($count + 1), $this->dbh->count());
$this->session->clear();
$this->connection->clear();
}
public function testLoadRelated() {
$coll = $this->session->query("FROM User(id)");
$coll = $this->connection->query("FROM User(id)");
$q = $coll->loadRelated();
......@@ -86,7 +86,7 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($count, $this->dbh->count());
}
public function testLoadRelatedForLocalKeyRelation() {
$coll = $this->session->query("FROM User");
$coll = $this->connection->query("FROM User");
$this->assertEqual($coll->count(), 8);
......@@ -107,10 +107,10 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$this->assertEqual(($count + 1), $this->dbh->count());
$this->session->clear();
$this->connection->clear();
}
public function testLoadRelatedForForeignKey() {
$coll = $this->session->query("FROM User");
$coll = $this->connection->query("FROM User");
$this->assertEqual($coll->count(), 8);
$count = $this->dbh->count();
......@@ -139,16 +139,16 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$this->assertEqual(($count + 1), $this->dbh->count());
$this->session->clear();
$this->connection->clear();
}
public function testCount() {
$coll = new Doctrine_Collection($this->session->getTable('User'));
$coll = new Doctrine_Collection($this->connection->getTable('User'));
$this->assertEqual($coll->count(), 0);
$coll[0];
$this->assertEqual($coll->count(), 1);
}
public function testExpand() {
$users = $this->session->query("FROM User-b.Phonenumber-l WHERE User.Phonenumber.phonenumber LIKE '%123%'");
$users = $this->connection->query("FROM User-b.Phonenumber-l WHERE User.Phonenumber.phonenumber LIKE '%123%'");
$this->assertTrue($users instanceof Doctrine_Collection_Batch);
$this->assertTrue($users[1] instanceof User);
......@@ -174,7 +174,7 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$coll->setGenerator($generator);
$generator = $coll->getGenerator();
$user = $this->session->getTable("User")->find(4);
$user = $this->connection->getTable("User")->find(4);
$this->assertEqual($generator->getIndex($user), 4);
}
......@@ -190,8 +190,8 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($coll["name"], $user);
$this->session->getTable("email")->setAttribute(Doctrine::ATTR_COLL_KEY,"address");
$emails = $this->session->getTable("email")->findAll();
$this->connection->getTable("email")->setAttribute(Doctrine::ATTR_COLL_KEY,"address");
$emails = $this->connection->getTable("email")->findAll();
foreach($emails as $k => $v) {
$this->assertTrue(gettype($k), "string");
}
......
......@@ -5,7 +5,7 @@ class Doctrine_ConfigurableTestCase extends Doctrine_UnitTestCase {
public function prepareTables() { }
public function prepareData() { }
public function testSetAttribute() {
$table = $this->session->getTable("User");
$table = $this->connection->getTable("User");
$this->manager->setAttribute(Doctrine::ATTR_CACHE_TTL,100);
$this->assertEqual($this->manager->getAttribute(Doctrine::ATTR_CACHE_TTL),100);
......@@ -52,11 +52,11 @@ class Doctrine_ConfigurableTestCase extends Doctrine_UnitTestCase {
}
try {
$this->session->beginTransaction();
$this->connection->beginTransaction();
$this->manager->setAttribute(Doctrine::ATTR_LOCKMODE, Doctrine::LOCK_OPTIMISTIC);
} catch(Exception $e) {
$this->assertTrue($e instanceof Exception);
$this->session->commit();
$this->connection->commit();
}
$e = false;
......@@ -82,11 +82,11 @@ class Doctrine_ConfigurableTestCase extends Doctrine_UnitTestCase {
$e = false;
try {
$this->session->beginTransaction();
$this->session->setAttribute(Doctrine::ATTR_LOCKMODE, Doctrine::LOCK_PESSIMISTIC);
$this->connection->beginTransaction();
$this->connection->setAttribute(Doctrine::ATTR_LOCKMODE, Doctrine::LOCK_PESSIMISTIC);
} catch(Exception $e) {
$this->assertTrue($e instanceof Exception);
$this->session->commit();
$this->connection->commit();
}
try {
$this->manager->setAttribute(Doctrine::ATTR_PK_TYPE,-12);
......
......@@ -16,9 +16,9 @@ class Doctrine_CustomPrimaryKeyTestCase extends Doctrine_UnitTestCase {
$c->save();
$this->assertEqual($c->getID(), array("uid" => 1));
$this->session->clear();
$this->connection->clear();
$c = $this->session->getTable('CustomPK')->find(1);
$c = $this->connection->getTable('CustomPK')->find(1);
$this->assertEqual($c->getID(), array("uid" => 1));
}
......
......@@ -3,10 +3,10 @@ require_once("UnitTestCase.php");
class Doctrine_EventListenerTestCase extends Doctrine_UnitTestCase {
public function testEvents() {
$session = $this->manager->openSession(Doctrine_DB::getConnection());
$connection = $this->manager->openConnection(Doctrine_DB::getConnection());
$debug = $this->listener->getMessages();
$last = end($debug);
$this->assertTrue($last->getObject() instanceof Doctrine_Session);
$this->assertTrue($last->getObject() instanceof Doctrine_Connection);
$this->assertTrue($last->getCode() == Doctrine_EventListener_Debugger::EVENT_OPEN);
}
public function prepareData() { }
......
......@@ -4,8 +4,8 @@ class Doctrine_ManagerTestCase extends Doctrine_UnitTestCase {
public function testGetInstance() {
$this->assertTrue(Doctrine_Manager::getInstance() instanceOf Doctrine_Manager);
}
public function testOpenSession() {
$this->assertTrue($this->session instanceOf Doctrine_Session);
public function testOpenConnection() {
$this->assertTrue($this->connection instanceOf Doctrine_Connection);
}
public function testGetIterator() {
$this->assertTrue($this->manager->getIterator() instanceof ArrayIterator);
......@@ -13,11 +13,11 @@ class Doctrine_ManagerTestCase extends Doctrine_UnitTestCase {
public function testCount() {
$this->assertEqual(count($this->manager),1);
}
public function testGetCurrentSession() {
$this->assertEqual($this->manager->getCurrentSession(), $this->session);
public function testGetCurrentConnection() {
$this->assertEqual($this->manager->getCurrentConnection(), $this->connection);
}
public function testGetSessions() {
$this->assertEqual(count($this->manager->getSessions()),1);
public function testGetConnections() {
$this->assertEqual(count($this->manager->getConnections()),1);
}
public function prepareData() { }
public function prepareTables() { }
......
......@@ -15,7 +15,7 @@ class Doctrine_PessimisticLockingTestCase extends Doctrine_UnitTestCase
public function setUp()
{
parent::setUp();
$this->lockingManager = new Doctrine_Locking_Manager_Pessimistic($this->session);
$this->lockingManager = new Doctrine_Locking_Manager_Pessimistic($this->connection);
// Create sample data to test on
$entry1 = new Forum_Entry();
......@@ -31,7 +31,7 @@ class Doctrine_PessimisticLockingTestCase extends Doctrine_UnitTestCase
*/
public function testLock()
{
$entries = $this->session->query("FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'");
$entries = $this->connection->query("FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'");
// Test successful lock
$gotLock = $this->lockingManager->getLock($entries[0], 'romanb');
......@@ -51,7 +51,7 @@ class Doctrine_PessimisticLockingTestCase extends Doctrine_UnitTestCase
*/
public function testReleaseAgedLocks()
{
$entries = $this->session->query("FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'");
$entries = $this->connection->query("FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'");
$this->lockingManager->getLock($entries[0], 'romanb');
$released = $this->lockingManager->releaseAgedLocks(-1); // age -1 seconds => release all
$this->assertTrue($released);
......@@ -64,4 +64,4 @@ class Doctrine_PessimisticLockingTestCase extends Doctrine_UnitTestCase
?>
\ No newline at end of file
?>
......@@ -8,7 +8,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
parent::prepareTables();
}
public function testLimitWithOneToOneLeftJoin() {
$q = new Doctrine_Query($this->session);
$q = new Doctrine_Query($this->connection);
$q->from('User(id).Email')->limit(5);
$users = $q->execute();
......@@ -17,7 +17,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
}
public function testLimitWithOneToOneInnerJoin() {
$q = new Doctrine_Query($this->session);
$q = new Doctrine_Query($this->connection);
$q->from('User(id):Email')->limit(5);
$users = $q->execute();
......@@ -51,7 +51,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
}
public function testLimitWithOneToManyLeftJoinAndCondition() {
$q = new Doctrine_Query($this->session);
$q = new Doctrine_Query($this->connection);
$q->from("User(name)")->where("User.Phonenumber.phonenumber LIKE '%123%'")->limit(5);
$users = $q->execute();
......@@ -68,7 +68,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
}
public function testLimitWithOneToManyLeftJoinAndOrderBy() {
$q = new Doctrine_Query($this->session);
$q = new Doctrine_Query($this->connection);
$q->from("User(name)")->where("User.Phonenumber.phonenumber LIKE '%123%'")->orderby("User.Email.address")->limit(5);
$users = $q->execute();
......@@ -147,11 +147,11 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
$users = $q->execute(array('zYne'));
$this->assertEqual($users->count(), 1);
$this->session->flush();
$this->connection->flush();
}
public function testLimitWithManyToManyColumnAggInheritanceLeftJoin() {
$q = new Doctrine_Query($this->session);
$q = new Doctrine_Query($this->connection);
$q->from("User.Group")->limit(5);
$users = $q->execute();
......@@ -169,7 +169,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($user->Group[0]->name, "Action Actors");
$this->session->flush();
$this->connection->flush();
$this->assertEqual($user->Group[0]->name, "Action Actors");
$this->assertEqual(count($user->Group), 3);
......@@ -182,7 +182,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($users->count(), 3);
$this->session->clear();
$this->connection->clear();
$q = new Doctrine_Query();
$q->from("User")->where("User.Group.id = ?")->orderby("User.id DESC");
$users = $q->execute(array($user->Group[1]->id));
......@@ -190,7 +190,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($users->count(), 3);
}
public function testLimitWithNormalManyToMany() {
$coll = new Doctrine_Collection($this->session->getTable("Photo"));
$coll = new Doctrine_Collection($this->connection->getTable("Photo"));
$tag = new Tag();
$tag->tag = "Some tag";
$coll[0]->Tag[0] = $tag;
......@@ -201,7 +201,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
$coll[2]->name = "photo 3";
$coll[3]->Tag[0]->tag = "Other tag";
$coll[3]->name = "photo 4";
$this->session->flush();
$this->connection->flush();
$q = new Doctrine_Query();
$q->from("Photo")->where("Photo.Tag.id = ?")->orderby("Photo.id DESC")->limit(100);
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
public function testQueryParser() {
$sql = "SELECT {p.*} FROM photos p";
$query = new Doctrine_RawSql($this->session);
$query = new Doctrine_RawSql($this->connection);
$query->parseQuery($sql);
$this->assertEqual($query->from, array('photos p'));
......@@ -19,7 +19,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
public function testAsteriskOperator() {
// Selecting with *
$query = new Doctrine_RawSql($this->session);
$query = new Doctrine_RawSql($this->connection);
$query->parseQuery("SELECT {entity.*} FROM entity");
$fields = $query->getFields();
......@@ -33,8 +33,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
}
public function testLazyPropertyLoading() {
$query = new Doctrine_RawSql($this->session);
$this->session->clear();
$query = new Doctrine_RawSql($this->connection);
$this->connection->clear();
// selecting proxy objects (lazy property loading)
......@@ -53,7 +53,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
}
public function testSmartMapping() {
$query = new Doctrine_RawSql($this->session);
$query = new Doctrine_RawSql($this->connection);
// smart component mapping (no need for additional addComponent call
$query->parseQuery("SELECT {entity.name}, {entity.id} FROM entity");
......@@ -70,7 +70,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
}
public function testMultipleComponents() {
$query = new Doctrine_RawSql($this->session);
$query = new Doctrine_RawSql($this->connection);
// multi component fetching
$query->parseQuery("SELECT {entity.name}, {entity.id}, {phonenumber.*} FROM entity LEFT JOIN phonenumber ON phonenumber.entity_id = entity.id");
......@@ -92,7 +92,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
public function testPrimaryKeySelectForcing() {
// forcing the select of primary key fields
$query = new Doctrine_RawSql($this->session);
$query = new Doctrine_RawSql($this->connection);
$query->parseQuery("SELECT {entity.name} FROM entity");
......@@ -104,7 +104,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
$this->assertTrue(is_numeric($coll[7]->id));
}
public function testMethodOverloading() {
$query = new Doctrine_RawSql($this->session);
$query = new Doctrine_RawSql($this->connection);
$query->select('{entity.name}')->from('entity');
$query->addComponent("entity", "User");
$coll = $query->execute();
......@@ -117,7 +117,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
public function testColumnAggregationInheritance() {
// forcing the select of primary key fields
$query = new Doctrine_RawSql($this->session);
$query = new Doctrine_RawSql($this->connection);
$query->parseQuery("SELECT {entity.name} FROM entity");
$query->addComponent("entity", "User");
......
......@@ -79,13 +79,13 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($e->Entity[0]->getState(), Doctrine_Record::STATE_CLEAN);
$this->assertEqual($e->Entity[1]->getState(), Doctrine_Record::STATE_CLEAN);
$coll = $this->session->query("FROM Entity WHERE Entity.name = 'Friend 1'");
$coll = $this->connection->query("FROM Entity WHERE Entity.name = 'Friend 1'");
$this->assertEqual($coll->count(), 1);
$this->assertEqual($coll[0]->getState(), Doctrine_Record::STATE_CLEAN);
$this->assertEqual($coll[0]->name, "Friend 1");
$query = new Doctrine_Query($this->session);
$query = new Doctrine_Query($this->connection);
$query->from("Entity.Entity")->where("Entity.Entity.name = 'Friend 1 1'");
......@@ -115,7 +115,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
}
public function testSerialize() {
$user = $this->session->getTable("User")->find(4);
$user = $this->connection->getTable("User")->find(4);
$str = serialize($user);
$user2 = unserialize($str);
......@@ -191,26 +191,26 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$record->entity1 = 2;
$record->save();
$coll = $this->session->query("FROM EntityReference-b");
$coll = $this->connection->query("FROM EntityReference-b");
$this->assertTrue($coll[0] instanceof EntityReference);
$this->assertEqual($coll[0]->getState(), Doctrine_Record::STATE_CLEAN);
$this->assertTrue($coll[1] instanceof EntityReference);
$this->assertEqual($coll[1]->getState(), Doctrine_Record::STATE_CLEAN);
$coll = $this->session->query("FROM EntityReference-b WHERE EntityReference.entity2 = 5");
$coll = $this->connection->query("FROM EntityReference-b WHERE EntityReference.entity2 = 5");
$this->assertEqual($coll->count(), 1);
}
public function testManyToManyTreeStructure() {
$task = $this->session->create("Task");
$task = $this->connection->create("Task");
$this->assertEqual($task->getTable()->getAlias("Resource"), "ResourceAlias");
$task->name = "Task 1";
$task->ResourceAlias[0]->name = "Resource 1";
$this->session->flush();
$this->connection->flush();
$this->assertTrue($task->ResourceAlias[0] instanceof Resource);
$this->assertEqual($task->ResourceAlias[0]->name, "Resource 1");
......@@ -234,7 +234,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($task->ResourceAlias->count(), 1);
$this->assertEqual($task->Subtask[0]->name, "Subtask 1");
$this->session->flush();
$this->connection->flush();
$task = $task->getTable()->find($task->getID());
......@@ -274,7 +274,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$account->amount = 2000;
$this->assertEqual($account->getTable()->getColumnNames(), array("id","entity_id","amount"));
$this->session->flush();
$this->connection->flush();
$this->assertEqual($user->getState(), Doctrine_Record::STATE_CLEAN);
$this->assertTrue($account instanceof Account);
......@@ -316,9 +316,9 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
}
public function testNewOperator() {
$table = $this->session->getTable("User");
$table = $this->connection->getTable("User");
$this->assertEqual($this->session->getTable("User")->getData(), array());
$this->assertEqual($this->connection->getTable("User")->getData(), array());
$user = new User();
$this->assertEqual(Doctrine_Lib::getRecordStateAsString($user->getState()), Doctrine_Lib::getRecordStateAsString(Doctrine_Record::STATE_TCLEAN));
$user->name = "John Locke";
......@@ -357,8 +357,8 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this->session->flush();
$elements = $this->session->query("FROM Element-l");
$this->connection->flush();
$elements = $this->connection->query("FROM Element-l");
$this->assertEqual($elements->count(), 5);
$e = $e->getTable()->find(1);
......@@ -422,7 +422,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$e->save();
$coll = $this->session->query("FROM Error-I");
$coll = $this->connection->query("FROM Error-I");
$e = $coll[0];
......@@ -467,7 +467,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$debug = $this->listener->getMessages();
$p = array_pop($debug);
$this->assertTrue($p->getObject() instanceof Doctrine_Session);
$this->assertTrue($p->getObject() instanceof Doctrine_Connection);
$this->assertTrue($p->getCode() == Doctrine_EventListener_Debugger::EVENT_COMMIT);
$user->delete();
......@@ -475,7 +475,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
}
public function testUpdate() {
$user = $this->session->getTable("User")->find(4);
$user = $this->connection->getTable("User")->find(4);
$user->set("name","Jack Daniels",true);
......@@ -487,7 +487,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$debug = $this->listener->getMessages();
$p = array_pop($debug);
$this->assertTrue($p->getObject() instanceof Doctrine_Session);
$this->assertTrue($p->getObject() instanceof Doctrine_Connection);
$this->assertTrue($p->getCode() == Doctrine_EventListener_Debugger::EVENT_COMMIT);
$p = array_pop($debug);
......@@ -501,7 +501,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
}
public function testCopy() {
$user = $this->session->getTable("User")->find(4);
$user = $this->connection->getTable("User")->find(4);
$new = $user->copy();
$this->assertTrue($new instanceof Doctrine_Record);
$this->assertTrue($new->getState() == Doctrine_Record::STATE_TDIRTY);
......@@ -511,7 +511,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$user = $this->objTable->find(5);
$pf = $this->session->getTable("Phonenumber");
$pf = $this->connection->getTable("Phonenumber");
$this->assertTrue($user->Phonenumber instanceof Doctrine_Collection);
$this->assertEqual($user->Phonenumber->count(), 3);
......@@ -615,7 +615,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
// REPLACING ONE-TO-ONE REFERENCES
$email = $this->session->create("Email");
$email = $this->connection->create("Email");
$email->address = "absolutist@nottodrink.com";
$user->Email = $email;
......@@ -628,7 +628,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this->assertTrue($user->Email instanceof Email);
$this->assertEqual($user->Email->address, "absolutist@nottodrink.com");
$emails = $this->session->query("FROM Email WHERE Email.id = $id");
$emails = $this->connection->query("FROM Email WHERE Email.id = $id");
//$this->assertEqual(count($emails),0);
}
......@@ -643,7 +643,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
public function testSaveAssociations() {
$user = $this->objTable->find(5);
$gf = $this->session->getTable("Group");
$gf = $this->connection->getTable("Group");
$this->assertTrue($user->Group instanceof Doctrine_Collection);
......@@ -743,13 +743,13 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
}
public function testCount() {
$user = $this->session->getTable("User")->find(4);
$user = $this->connection->getTable("User")->find(4);
$this->assertTrue(is_integer($user->count()));
}
public function testGetReference() {
$user = $this->session->getTable("User")->find(4);
$user = $this->connection->getTable("User")->find(4);
$this->assertTrue($user->Email instanceof Doctrine_Record);
$this->assertTrue($user->Phonenumber instanceof Doctrine_Collection);
......@@ -758,7 +758,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this->assertTrue($user->Phonenumber->count() == 1);
}
public function testGetIterator() {
$user = $this->session->getTable("User")->find(4);
$user = $this->connection->getTable("User")->find(4);
$this->assertTrue($user->getIterator() instanceof ArrayIterator);
}
......
......@@ -2,11 +2,11 @@
require_once("UnitTestCase.php");
class Doctrine_TableTestCase extends Doctrine_UnitTestCase {
public function testBind() {
$table = $this->session->getTable("User");
$table = $this->connection->getTable("User");
}
public function testGetIdentifier() {
$table = $this->session->getTable("User");
$table = $this->connection->getTable("User");
}
public function testGetForeignKey() {
$fk = $this->objTable->getForeignKey("Group");
......@@ -39,8 +39,8 @@ class Doctrine_TableTestCase extends Doctrine_UnitTestCase {
public function testGetTableName() {
$this->assertTrue($this->objTable->getTableName() == "entity");
}
public function testGetSession() {
$this->assertTrue($this->objTable->getSession() instanceof Doctrine_Session);
public function testGetConnection() {
$this->assertTrue($this->objTable->getConnection() instanceof Doctrine_Connection);
}
public function testGetData() {
$this->assertTrue($this->objTable->getData() == array());
......
......@@ -19,7 +19,7 @@ require_once("simpletest/reporter.php");
class Doctrine_UnitTestCase extends UnitTestCase {
protected $manager;
protected $session;
protected $connection;
protected $objTable;
protected $new;
protected $old;
......@@ -63,24 +63,24 @@ class Doctrine_UnitTestCase extends UnitTestCase {
if($this->manager->count() > 0) {
$this->session = $this->manager->getSession(0);
$this->session->evictTables();
$this->dbh = $this->session->getDBH();
$this->connection = $this->manager->getConnection(0);
$this->connection->evictTables();
$this->dbh = $this->connection->getDBH();
$this->listener = $this->manager->getAttribute(Doctrine::ATTR_LISTENER);
} else {
//$this->dbh = Doctrine_DB::getConnection();
$this->dbh = Doctrine_DB::getConn("sqlite::memory:");
//$this->dbh = new PDO("sqlite::memory:");
$this->session = $this->manager->openSession($this->dbh);
$this->connection = $this->manager->openConnection($this->dbh);
$this->listener = new Doctrine_EventListener_Debugger();
$this->manager->setAttribute(Doctrine::ATTR_LISTENER, $this->listener);
}
$this->query = new Doctrine_Query($this->session);
$this->query = new Doctrine_Query($this->connection);
$this->prepareTables();
$this->prepareData();
$this->valueHolder = new Doctrine_ValueHolder($this->session->getTable('User'));
$this->valueHolder = new Doctrine_ValueHolder($this->connection->getTable('User'));
}
public function prepareTables() {
foreach($this->tables as $name) {
......@@ -94,15 +94,15 @@ class Doctrine_UnitTestCase extends UnitTestCase {
foreach($this->tables as $name) {
$name = ucwords($name);
$table = $this->session->getTable($name);
$table = $this->connection->getTable($name);
$table->getCache()->deleteAll();
$table->clear();
}
$this->objTable = $this->session->getTable("User");
$this->objTable = $this->connection->getTable("User");
}
public function prepareData() {
$groups = new Doctrine_Collection($this->session->getTable("Group"));
$groups = new Doctrine_Collection($this->connection->getTable("Group"));
$groups[0]->name = "Drama Actors";
......@@ -113,7 +113,7 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$groups[2]["Phonenumber"][0]->phonenumber = "123 123";
$groups->save();
$users = new Doctrine_Collection($this->session->getTable("User"));
$users = new Doctrine_Collection($this->connection->getTable("User"));
$users[0]->name = "zYne";
......@@ -156,14 +156,14 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$users[7]->Phonenumber[0]->phonenumber = "111 567 333";
$this->users = $users;
$this->session->flush();
$this->connection->flush();
}
public function getSession() {
return $this->session;
public function getConnection() {
return $this->connection;
}
public function clearCache() {
foreach($this->tables as $name) {
$table = $this->session->getTable($name);
$table = $this->connection->getTable($name);
$table->getCache()->deleteAll();
}
}
......
......@@ -93,7 +93,7 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
}
public function testValidate() {
$user = $this->session->getTable("User")->find(4);
$user = $this->connection->getTable("User")->find(4);
$set = array("password" => "this is an example of too long password",
"loginname" => "this is an example of too long loginname",
......@@ -129,7 +129,7 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
$validator = new Doctrine_Validator_Email();
$email = $this->session->create("Email");
$email = $this->connection->create("Email");
$this->assertFalse($validator->validate($email,"address","example@example",null));
$this->assertFalse($validator->validate($email,"address","example@@example",null));
$this->assertFalse($validator->validate($email,"address","example@example.",null));
......@@ -141,7 +141,7 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
}
public function testSave() {
$this->manager->setAttribute(Doctrine::ATTR_VLD, true);
$user = $this->session->getTable("User")->find(4);
$user = $this->connection->getTable("User")->find(4);
try {
$user->name = "this is an example of too long name not very good example but an example nevertheless";
$user->save();
......@@ -150,7 +150,7 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
}
try {
$user = $this->session->create("User");
$user = $this->connection->create("User");
$user->Email->address = "jackdaniels@drinkmore.info...";
$user->name = "this is an example of too long user name not very good example but an example nevertheles";
$user->save();
......
......@@ -17,7 +17,7 @@ class Doctrine_ValueHolder_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($this->valueHolder->get('key'), 'second');
}
public function testSimpleQuery() {
$q = new Doctrine_Query($this->session);
$q = new Doctrine_Query($this->connection);
$q->from("User");
$users = $q->execute(array(), Doctrine::FETCH_VHOLDER);
$this->assertEqual($users->count(), 8);
......@@ -25,7 +25,7 @@ class Doctrine_ValueHolder_TestCase extends Doctrine_UnitTestCase {
}
public function testQueryWithOneToManyRelation() {
$q = new Doctrine_Query($this->session);
$q = new Doctrine_Query($this->connection);
$q->from("User.Phonenumber");
$users = $q->execute(array(), Doctrine::FETCH_VHOLDER);
$this->assertEqual($users->count(), 8);
......
<?php
class Doctrine_ViewTestCase extends Doctrine_UnitTestCase {
public function testCreateView() {
$query = new Doctrine_Query($this->session);
$query = new Doctrine_Query($this->connection);
$query->from('User');
$view = new Doctrine_View($query, 'MyView');
......@@ -38,6 +38,6 @@ class Doctrine_ViewTestCase extends Doctrine_UnitTestCase {
}
public function testConstructor() {
}
}
}
?>
......@@ -47,8 +47,8 @@ class Address extends Doctrine_Record {
}
}
// grouptable doesn't extend Doctrine_Table -> Doctrine_Session
// won't initialize grouptable when Doctrine_Session->getTable("Group") is called
// grouptable doesn't extend Doctrine_Table -> Doctrine_Connection
// won't initialize grouptable when Doctrine_Connection->getTable("Group") is called
class GroupTable { }
class Group extends Entity {
......
......@@ -3,7 +3,7 @@ ob_start();
require_once("ConfigurableTestCase.php");
require_once("ManagerTestCase.php");
require_once("SessionTestCase.php");
require_once("ConnectionTestCase.php");
require_once("TableTestCase.php");
require_once("EventListenerTestCase.php");
require_once("BatchIteratorTestCase.php");
......@@ -31,7 +31,7 @@ $test = new GroupTest("Doctrine Framework Unit Tests");
$test->addTestCase(new Doctrine_RecordTestCase());
$test->addTestCase(new Doctrine_SessionTestCase());
$test->addTestCase(new Doctrine_ConnectionTestCase());
$test->addTestCase(new Doctrine_TableTestCase());
......@@ -76,7 +76,7 @@ $test->addTestCase(new Doctrine_Query_Limit_TestCase());
print "<pre>";
$test->run(new HtmlReporter());
/**
$cache = Doctrine_Manager::getInstance()->getCurrentSession()->getCacheHandler();
$cache = Doctrine_Manager::getInstance()->getCurrentConnection()->getCacheHandler();
if(isset($cache)) {
$a = $cache->getQueries();
print "Executed cache queries: ".count($a)."\n";
......@@ -88,7 +88,7 @@ if(isset($cache)) {
}
*/
$dbh = Doctrine_Manager::getInstance()->getCurrentSession()->getDBH();
$dbh = Doctrine_Manager::getInstance()->getCurrentConnection()->getDBH();
$a = $dbh->getQueries();
print "Executed queries: ".count($a)."\n";
......
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