[英]codeception : Setting the “doctrine” pre-defined service is deprecated since Symfony 3.3 and won't be supported anymore in Symfony 4.0
我的项目是一个带有Doctrine ORM的Symfony 3.3.9项目。 我使用代码库2.3.6与模块Doctrine2,我遵循这篇文章: http ://codeception.com/docs/modules/Doctrine2
我的代码配置是:
#tests/functional.suite.yml
actor: FunctionalTester
modules:
enabled:
- \Helper\Functional
- PhpBrowser:
url: http://localhost
- Symfony
- Doctrine2:
depends: Symfony
cleanup: true
当我使用此命令运行测试套件时
./vendor/bin/codecept run functional
测试在Success中传递得很好,但是抛弃了已弃用的消息:
自Symfony 3.3以来,不再支持设置“doctrine”预定义服务,Symfony 4.0将不再支持
当我从functional.suite.yml中删除Doctrine2模块的配置时
#tests/functional.suite.yml
actor: FunctionalTester
modules:
enabled:
- \Helper\Functional
- PhpBrowser:
url: http://localhost
- Symfony
我必须在我的测试类中删除$I->grabEntityFromRepository()
的调用,并且不推荐使用会消失
我的项目也有同样的问题。 该问题在github https://github.com/Codeception/Codeception/issues/4318上打开
问题不在于代码的Doctrine2模块,而在于代码的Symfony模块。
方法Codeception \\ Module \\ Symfony :: _ getEntityManager()想要持久化3个服务doctrine,doctrine.orm.default_entity_manager,doctrine.dbal.backend_connection
public function _getEntityManager()
{
if ($this->kernel === null) {
$this->fail('Symfony2 platform module is not loaded');
}
if (!isset($this->permanentServices[$this->config['em_service']])) {
// try to persist configured EM
$this->persistService($this->config['em_service'], true);
if ($this->_getContainer()->has('doctrine')) {
$this->persistService('doctrine', true);
}
if ($this->_getContainer()->has('doctrine.orm.default_entity_manager')) {
$this->persistService('doctrine.orm.default_entity_manager', true);
}
if ($this->_getContainer()->has('doctrine.dbal.backend_connection')) {
$this->persistService('doctrine.dbal.backend_connection', true);
}
}
return $this->permanentServices[$this->config['em_service']];
}
从Codeception \\ Lib \\ Connector \\ Symfony :: rebootKernel()触发错误:
public function rebootKernel()
{
foreach ($this->persistentServices as $serviceName => $service) {
$this->container->set($serviceName, $service);
}
}
你可以评论github的问题,它现在没有关闭。
编辑:您可以在配置文件中定义error_level并添加~E_USER_DEPRECATED:
#tests/functional.suite.yml
actor: FunctionalTester
modules:
enabled:
- \Helper\Functional
- PhpBrowser:
url: http://localhost
- Symfony
- Doctrine2:
depends: Symfony
cleanup: true
error_level: "E_ALL & ~E_STRICT & ~E_DEPRECATED & ~E_USER_DEPRECATED"
http://codeception.com/docs/04-FunctionalTests#Error-Reporting
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.