From 4a9369de9e60498924c75c76b229fa0a2a099c30 Mon Sep 17 00:00:00 2001 From: "Roman S. Borschel" Date: Mon, 7 Jun 2010 00:14:43 +0200 Subject: [PATCH] Fixed incorrect transaction management in locking tests. --- .../Tests/ORM/Functional/Locking/LockTest.php | 16 ++++++++++++++-- .../Tests/ORM/Functional/Ticket/DDC144Test.php | 1 - .../Tests/ORM/Functional/Ticket/DDC353Test.php | 5 +---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php index c5316f769..6917e7252 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php @@ -125,7 +125,13 @@ class LockTest extends \Doctrine\Tests\OrmFunctionalTestCase { $this->_em->flush(); $this->_em->beginTransaction(); - $this->_em->lock($article, LockMode::PESSIMISTIC_WRITE); + try { + $this->_em->lock($article, LockMode::PESSIMISTIC_WRITE); + $this->_em->commit(); + } catch (\Exception $e) { + $this->_em->rollback(); + throw $e; + } $query = array_pop( $this->_sqlLoggerStack->queries ); $this->assertContains($writeLockSql, $query['sql']); @@ -149,7 +155,13 @@ class LockTest extends \Doctrine\Tests\OrmFunctionalTestCase { $this->_em->flush(); $this->_em->beginTransaction(); - $this->_em->lock($article, LockMode::PESSIMISTIC_READ); + try { + $this->_em->lock($article, LockMode::PESSIMISTIC_READ); + $this->_em->commit(); + } catch (\Exception $e) { + $this->_em->rollback(); + throw $e; + } $query = array_pop( $this->_sqlLoggerStack->queries ); $this->assertContains($readLockSql, $query['sql']); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php index 9b493e7da..82a2e314c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php @@ -8,7 +8,6 @@ class DDC144Test extends \Doctrine\Tests\OrmFunctionalTestCase { protected function setUp() { parent::setUp(); - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); $this->_schemaTool->createSchema(array( diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php index 5091cd44c..40f4ca298 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php @@ -10,15 +10,12 @@ class DDC353Test extends \Doctrine\Tests\OrmFunctionalTestCase protected function setUp() { parent::setUp(); - try { $this->_schemaTool->createSchema(array( $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC353File'), $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC353Picture'), )); - } catch(\Exception $e) { - - } + } catch(\Exception $ignored) {} } public function testWorkingCase()