codeception : 设置 "doctrine" 预定义服务自 Symfony 3.3 起已弃用,Symfony 4.0 将不再支持
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 项目。
我将 codeception 2.3.6 与模块 Doctrine2 一起使用,我关注这篇文章:http://codeception.com/docs/modules/Doctrine2
我的codeception配置是:
#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
测试顺利通过并成功,但会抛出弃用的消息:
设置 "doctrine" 预定义服务自 Symfony 3.3 起已弃用,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
上打开
问题不在codeception的Doctrine2模块,而是在codeception的Symfony模块。
方法 Codeception\Module\Symfony::_getEntityManager() 想要坚持 3 服务原则,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
我的项目是一个带有 Doctrine ORM 的 Symfony 3.3.9 项目。 我将 codeception 2.3.6 与模块 Doctrine2 一起使用,我关注这篇文章:http://codeception.com/docs/modules/Doctrine2
我的codeception配置是:
#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
测试顺利通过并成功,但会抛出弃用的消息:
设置 "doctrine" 预定义服务自 Symfony 3.3 起已弃用,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
上打开问题不在codeception的Doctrine2模块,而是在codeception的Symfony模块。
方法 Codeception\Module\Symfony::_getEntityManager() 想要坚持 3 服务原则,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