From c6a6aaf493671820856341d76d9c475a45ff2127 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Fri, 3 Dec 2010 17:44:24 +0100 Subject: [PATCH] DDC-899 - Add method to check if EntityManager is still open. --- lib/Doctrine/ORM/EntityManager.php | 10 ++++++++++ tests/Doctrine/Tests/ORM/EntityManagerTest.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 0ab1541ba..3af9cf3c3 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -619,6 +619,16 @@ class EntityManager } } + /** + * Check if the Entity manager is open or closed. + * + * @return bool + */ + public function isOpen() + { + return (!$this->closed); + } + /** * Gets the UnitOfWork used by the EntityManager to coordinate operations. * diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index ad5f41de7..a2fe796d6 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -14,6 +14,16 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase $this->_em = $this->_getTestEntityManager(); } + /** + * @group DDC-899 + */ + public function testIsOpen() + { + $this->assertTrue($this->_em->isOpen()); + $this->_em->close(); + $this->assertFalse($this->_em->isOpen()); + } + public function testGetConnection() { $this->assertType('\Doctrine\DBAL\Connection', $this->_em->getConnection());