Php codeception:设置;“信条”;自Symfony 3.3和won';Symfony 4.0不再支持
我的项目是一个Symfony 3.3.9项目,带有ORM。 我将codeception 2.3.6与模块Doctrine2一起使用,我将遵循本文: 我的codeception配置为:Php codeception:设置;“信条”;自Symfony 3.3和won';Symfony 4.0不再支持,php,symfony,testing,doctrine-orm,codeception,Php,Symfony,Testing,Doctrine Orm,Codeception,我的项目是一个Symfony 3.3.9项目,带有ORM。 我将codeception 2.3.6与模块Doctrine2一起使用,我将遵循本文: 我的codeception配置为: #tests/functional.suite.yml actor: FunctionalTester modules: enabled: - \Helper\Functional - PhpBrowser: url: http://localhost
#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
测试顺利通过,但会抛出不推荐的消息:
自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->grabentyfromrepository()
的调用,不推荐的调用将消失我的项目也有同样的问题。
该问题在github上公开
问题不在于codeception的Doctrine2模块,而在于codeception的Symfony模块
方法Codeception\Module\Symfony::\u getEntityManager()希望持久化3个服务条令、条令.orm.default\u实体\u管理器、条令.dbal.backend\u连接
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()触发的:
你可以评论github的问题,它现在还没有关闭
编辑:您可以在配置文件中定义错误级别并添加~E\u USER\u 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"
那么,如何删除此不推荐使用的邮件?您可以在github上提问。尝试将错误级别:“E_ALL&~E_STRICT&~E_DEPRECATED&~E_USER_DEPRECATED”`配置到codeception.yml filethx中,没有真正的解决方案。很高兴知道github上存在问题;)没有人在处理这个问题。欢迎提出解决办法。
#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"