So, when I run tests in my ZF / Doctrine application, some tests happen to break the Doctrine Entity Manager, and all consecutive tests fail because EM is closed.
I install EM in my /bootstrap.php tests:
$application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); $application->bootstrap(); (...) $bootstrap = $application->getBootstrap(); $em = $bootstrap->getResource('doctrinemanager');
Then I install it inside the setUp () function ($ this → _ service is the checked service):
$em = App::getEntityManager(); $this->_em = clone $em; $this->_service->setEm($this->_em);
And then, when I run a test that causes EM to throw an exception and close (and that is the correct behavior for me), it remains closed in all tests, which, of course, cannot complete due to EM closing. This is simply not the behavior that I expect for tests, as you might guess.
I tried to clone EM before installing it in the service, but that did not work.
Is there an easy way to reopen EM using some Doctrine methods?
source share