Open pawelryznar opened 5 years ago
_getEntityManager
method is called in _beforeSuite
when it isn't initialized yet.
I think that it should be enough to add this code to _getEntityManager
:
if (!isset($this->container)) {
$this->container = $this->client->getContainer();
}
It would be a completely different story to get DataFactory and Doctrine modules working with recreateApplicationBetweenRequests
, because it is necessary to make Doctrine instance persist between requests.
ZF2 module does it like this, ZendExpressive module would have to work with all 3 supported service managers.
No that doesn't work. I tried it already and then realised that in vendor/codeception/codeception/src/Codeception/Module/ZendExpressive.php
there are deprecation comments for two properties
/**
* @var \Interop\Container\ContainerInterface
* @deprecated Doesn't work as expected if Application is recreated between requests
*/
public $container;
/**
* @var \Zend\Expressive\Application
* @deprecated Doesn't work as expected if Application is recreated between requests
*/
public $application;
deprecated tags are for direct access to these properties, I will make them private in the next major version.
This causes more problems than I thought, because in one of the middlewares we add Doctrine filters. So all tests are working when executed separately, but when run all at once, only first one is passing.
What are you trying to achieve?
I'm trying to use use FactoryMuffin for tests in my Zend Expressive application. With default setting recreateApplicationBetweenTests: true for ZendExpressive module tests don't work. I'm getting an exception. Changing config to recreateApplicationBetweenTests: false helps but I need to use recreateApplicationBetweenTests: true.
What do you get instead?
Details
Codeception version: 3.1.0
PHP Version: 7.1.3
Operating System: MacOS
Installation type: Composer
List of installed packages (
composer show
)Suite configuration: \Tests\Helper\Api extends \Codeception\Module\ZendExpressive