fixed references to deprecated getTransaction() and getUnitOfWork() methods
This commit is contained in:
parent
4f361df6c3
commit
6daa1e3443
@ -47,7 +47,7 @@ abstract class Doctrine_Configurable {
|
||||
*
|
||||
* <code>
|
||||
* $manager->setAttribute(Doctrine::ATTR_PORTABILITY, Doctrine::PORTABILITY_ALL);
|
||||
*
|
||||
*
|
||||
* // or
|
||||
*
|
||||
* $manager->setAttribute('portability', Doctrine::PORTABILITY_ALL);
|
||||
@ -76,12 +76,12 @@ abstract class Doctrine_Configurable {
|
||||
break;
|
||||
case Doctrine::ATTR_LOCKMODE:
|
||||
if($this instanceof Doctrine_Connection) {
|
||||
if($this->getTransaction()->getState() != Doctrine_Connection_Transaction::STATE_OPEN)
|
||||
if($this->transaction->getState() != Doctrine_Connection_Transaction::STATE_OPEN)
|
||||
throw new Doctrine_Exception("Couldn't set lockmode. There are transactions open.");
|
||||
|
||||
} elseif($this instanceof Doctrine_Manager) {
|
||||
foreach($this as $connection) {
|
||||
if($connection->getTransaction()->getState() != Doctrine_Connection_Transaction::STATE_OPEN)
|
||||
if($connection->transaction->getState() != Doctrine_Connection_Transaction::STATE_OPEN)
|
||||
throw new Doctrine_Exception("Couldn't set lockmode. There are transactions open.");
|
||||
}
|
||||
} else {
|
||||
|
@ -864,12 +864,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
$conn->beginTransaction();
|
||||
|
||||
|
||||
$saveLater = $conn->getUnitOfWork()->saveRelated($this);
|
||||
$saveLater = $conn->unitOfWork->saveRelated($this);
|
||||
|
||||
if ($this->isValid()) {
|
||||
$conn->save($this);
|
||||
} else {
|
||||
$conn->getTransaction()->addInvalid($this);
|
||||
$conn->transaction->addInvalid($this);
|
||||
}
|
||||
|
||||
foreach($saveLater as $fk) {
|
||||
@ -884,7 +884,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
|
||||
// save the MANY-TO-MANY associations
|
||||
|
||||
$conn->getUnitOfWork()->saveAssociations($this);
|
||||
$conn->unitOfWork->saveAssociations($this);
|
||||
//$this->saveAssociations();
|
||||
|
||||
$conn->commit();
|
||||
|
@ -1,109 +1,6 @@
|
||||
<?php
|
||||
require_once("UnitTestCase.php");
|
||||
class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
public function testbuildFlushTree() {
|
||||
$correct = array("Task","ResourceType","Resource","Assignment","ResourceReference");
|
||||
|
||||
// new model might switch some many-to-many components (NO HARM!)
|
||||
|
||||
$correct2 = array (
|
||||
0 => 'Resource',
|
||||
1 => 'Task',
|
||||
2 => 'ResourceType',
|
||||
3 => 'Assignment',
|
||||
4 => 'ResourceReference',
|
||||
);
|
||||
|
||||
$task = new Task();
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Task"));
|
||||
$this->assertEqual($tree,array("Resource","Task","Assignment"));
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Task","Resource"));
|
||||
$this->assertEqual($tree,$correct);
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Task","Assignment","Resource"));
|
||||
$this->assertEqual($tree,$correct);
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Assignment","Task","Resource"));
|
||||
|
||||
$this->assertEqual($tree,$correct2);
|
||||
|
||||
|
||||
$correct = array("Forum_Category","Forum_Board","Forum_Thread");
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Category","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$correct = array("Forum_Category","Forum_Board","Forum_Thread","Forum_Entry");
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Entry","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Board","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Thread","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Board","Forum_Thread"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Board","Forum_Thread","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Board","Forum_Entry","Forum_Thread"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Entry","Forum_Board","Forum_Thread"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Entry","Forum_Thread","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Thread","Forum_Board","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Thread","Forum_Entry","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Board","Forum_Thread","Forum_Category"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Category","Forum_Thread","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Thread","Forum_Board","Forum_Category"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Board","Forum_Thread","Forum_Category","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Board","Forum_Thread","Forum_Entry","Forum_Category"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Board","Forum_Category","Forum_Thread","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Entry","Forum_Thread","Forum_Board","Forum_Category"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Entry","Forum_Thread","Forum_Category","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Entry","Forum_Category","Forum_Board","Forum_Thread"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Thread","Forum_Category","Forum_Board","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Thread","Forum_Entry","Forum_Category","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Thread","Forum_Board","Forum_Entry","Forum_Category"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Category","Forum_Entry","Forum_Board","Forum_Thread"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Category","Forum_Thread","Forum_Entry","Forum_Board"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
$tree = $this->connection->getUnitOfWork()->buildFlushTree(array("Forum_Category","Forum_Board","Forum_Thread","Forum_Entry"));
|
||||
$this->assertEqual($tree, $correct);
|
||||
|
||||
}
|
||||
|
||||
public function testBulkInsert() {
|
||||
$u1 = new User();
|
||||
$u1->name = "Jean Reno";
|
||||
@ -111,7 +8,22 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$id = $u1->obtainIdentifier();
|
||||
$u1->delete();
|
||||
|
||||
}
|
||||
|
||||
public function testUnknownModule() {
|
||||
try {
|
||||
$this->connection->unknown;
|
||||
$this->fail();
|
||||
} catch(Doctrine_Connection_Exception $e) {
|
||||
$this->pass();
|
||||
}
|
||||
}
|
||||
public function testGetModule() {
|
||||
$this->assertTrue($this->connection->unitOfWork instanceof Doctrine_Connection_UnitOfWork);
|
||||
//$this->assertTrue($this->connection->dataDict instanceof Doctrine_DataDict);
|
||||
$this->assertTrue($this->connection->expression instanceof Doctrine_Expression);
|
||||
$this->assertTrue($this->connection->transaction instanceof Doctrine_Transaction);
|
||||
$this->assertTrue($this->connection->export instanceof Doctrine_Export);
|
||||
}
|
||||
|
||||
public function testFlush() {
|
||||
@ -312,8 +224,8 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertTrue($this->connection->getIterator() instanceof ArrayIterator);
|
||||
}
|
||||
public function testGetState() {
|
||||
$this->assertEqual($this->connection->getTransaction()->getState(),Doctrine_Connection_Transaction::STATE_OPEN);
|
||||
$this->assertEqual(Doctrine_Lib::getConnectionStateAsString($this->connection->getTransaction()->getState()), "open");
|
||||
$this->assertEqual($this->connection->transaction->getState(),Doctrine_Connection_Transaction::STATE_OPEN);
|
||||
$this->assertEqual(Doctrine_Lib::getConnectionStateAsString($this->connection->transaction->getState()), "open");
|
||||
}
|
||||
public function testGetTables() {
|
||||
$this->assertTrue(is_array($this->connection->getTables()));
|
||||
@ -322,9 +234,9 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
|
||||
public function testTransactions() {
|
||||
|
||||
$this->connection->beginTransaction();
|
||||
$this->assertEqual($this->connection->getTransaction()->getState(),Doctrine_Connection_Transaction::STATE_ACTIVE);
|
||||
$this->assertEqual($this->connection->transaction->getState(),Doctrine_Connection_Transaction::STATE_ACTIVE);
|
||||
$this->connection->commit();
|
||||
$this->assertEqual($this->connection->getTransaction()->getState(),Doctrine_Connection_Transaction::STATE_OPEN);
|
||||
$this->assertEqual($this->connection->transaction->getState(),Doctrine_Connection_Transaction::STATE_OPEN);
|
||||
|
||||
$this->connection->beginTransaction();
|
||||
|
||||
@ -341,26 +253,26 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
public function testRollback() {
|
||||
$this->connection->beginTransaction();
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),1);
|
||||
$this->assertEqual($this->connection->getTransaction()->getState(),Doctrine_Connection_Transaction::STATE_ACTIVE);
|
||||
$this->assertEqual($this->connection->transaction->getTransactionLevel(),1);
|
||||
$this->assertEqual($this->connection->transaction->getState(), Doctrine_Connection_Transaction::STATE_ACTIVE);
|
||||
$this->connection->rollback();
|
||||
$this->assertEqual($this->connection->getTransaction()->getState(),Doctrine_Connection_Transaction::STATE_OPEN);
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),0);
|
||||
$this->assertEqual($this->connection->transaction->getState(), Doctrine_Connection_Transaction::STATE_OPEN);
|
||||
$this->assertEqual($this->connection->transaction->getTransactionLevel(),0);
|
||||
}
|
||||
public function testNestedTransactions() {
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),0);
|
||||
$this->assertEqual($this->connection->transaction->getTransactionLevel(),0);
|
||||
$this->connection->beginTransaction();
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),1);
|
||||
$this->assertEqual($this->connection->getTransaction()->getState(),Doctrine_Connection_Transaction::STATE_ACTIVE);
|
||||
$this->assertEqual($this->connection->transaction->getTransactionLevel(),1);
|
||||
$this->assertEqual($this->connection->transaction->getState(),Doctrine_Connection_Transaction::STATE_ACTIVE);
|
||||
$this->connection->beginTransaction();
|
||||
$this->assertEqual($this->connection->getTransaction()->getState(),Doctrine_Connection_Transaction::STATE_BUSY);
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),2);
|
||||
$this->assertEqual($this->connection->transaction->getState(),Doctrine_Connection_Transaction::STATE_BUSY);
|
||||
$this->assertEqual($this->connection->transaction->getTransactionLevel(),2);
|
||||
$this->connection->commit();
|
||||
$this->assertEqual($this->connection->getTransaction()->getState(),Doctrine_Connection_Transaction::STATE_ACTIVE);
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),1);
|
||||
$this->assertEqual($this->connection->transaction->getState(),Doctrine_Connection_Transaction::STATE_ACTIVE);
|
||||
$this->assertEqual($this->connection->transaction->getTransactionLevel(),1);
|
||||
$this->connection->commit();
|
||||
$this->assertEqual($this->connection->getTransaction()->getState(),Doctrine_Connection_Transaction::STATE_OPEN);
|
||||
$this->assertEqual($this->connection->getTransactionLevel(),0);
|
||||
$this->assertEqual($this->connection->transaction->getState(),Doctrine_Connection_Transaction::STATE_OPEN);
|
||||
$this->assertEqual($this->connection->transaction->getTransactionLevel(),0);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -30,6 +30,7 @@ class Doctrine_UnitTestCase extends UnitTestCase {
|
||||
protected $users;
|
||||
protected $valueHolder;
|
||||
protected $tables = array();
|
||||
protected $unitOfWork;
|
||||
|
||||
private $init = false;
|
||||
|
||||
@ -79,7 +80,7 @@ class Doctrine_UnitTestCase extends UnitTestCase {
|
||||
$this->listener = new Doctrine_EventListener_Debugger();
|
||||
$this->manager->setAttribute(Doctrine::ATTR_LISTENER, $this->listener);
|
||||
}
|
||||
|
||||
$this->unitOfWork = $this->connection->unitOfWork;
|
||||
$this->connection->setListener(new Doctrine_EventListener());
|
||||
$this->query = new Doctrine_Query($this->connection);
|
||||
$this->prepareTables();
|
||||
|
@ -43,6 +43,8 @@ require_once('QueryShortAliasesTestCase.php');
|
||||
require_once('QueryDeleteTestCase.php');
|
||||
require_once('QueryUpdateTestCase.php');
|
||||
|
||||
require_once('UnitOfWorkTestCase.php');
|
||||
|
||||
require_once('RelationAccessTestCase.php');
|
||||
require_once('RelationTestCase.php');
|
||||
require_once('RelationManyToManyTestCase.php');
|
||||
@ -67,6 +69,10 @@ print '<pre>';
|
||||
|
||||
$test = new GroupTest('Doctrine Framework Unit Tests');
|
||||
|
||||
$test->addTestCase(new Doctrine_UnitOfWork_TestCase());
|
||||
|
||||
$test->addTestCase(new Doctrine_ConnectionTestCase());
|
||||
|
||||
$test->addTestCase(new Doctrine_Db_TestCase());
|
||||
|
||||
$test->addTestCase(new Doctrine_Db_Profiler_TestCase());
|
||||
@ -75,8 +81,6 @@ $test->addTestCase(new Doctrine_Query_MultiJoin_TestCase());
|
||||
|
||||
$test->addTestCase(new Doctrine_Record_TestCase());
|
||||
|
||||
$test->addTestCase(new Doctrine_ConnectionTestCase());
|
||||
|
||||
$test->addTestCase(new Doctrine_DataDict_Pgsql_TestCase());
|
||||
|
||||
$test->addTestCase(new Doctrine_Relation_ManyToMany_TestCase());
|
||||
|
Loading…
x
Reference in New Issue
Block a user