我正在使用代码(验收测试)与Symfony和Doctrine2模块结合使用。
当我将Symfony配置为使用单个数据库连接时,一切正常,我的测试完成。但是一旦我添加数据库从属连接,就会出现以下异常并且测试失败:
1) SomeCest: Some test
Test tests/acceptance/SomeCest.php:someTest
[PHPUnit\Framework\Exception] Undefined property: Doctrine\DBAL\Connections\MasterSlaveConnection::$_conn
#1 /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php:154
#2 Codeception\Subscriber\Module->before
#3 /var/www/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:184
#4 /var/www/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:46
我无法理解这个错误是如何产生的,因为在声明的文件(MasterSlaveConnection.php
)中,该类明显地从Connection
扩展而来,其中定义了属性$_conn
。
有人可以帮我吗?这是一个错误,我应该在codeception github页面上打开一个错误报告吗?或者我做错了什么?提前谢谢!
acceptance.suite.yml:
actor: AcceptanceTester
modules:
enabled:
- Symfony:
part: SERVICES
environment: 'prod'
- Doctrine2:
depends: Symfony
cleanup: false
- WebDriver:
url: 'http://localhost/'
browser: phantomjs
restart: true
clear_cookies: true
log_js_errors: true
window_size: 1960x1080
app / config / config.yml,具有单一数据库配置:
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
app / config / config.yml,具有多个数据库配置:
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
slaves:
slave1:
host: "%database_host2%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
slave2:
host: "%database_host3%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
我正在使用symfony 2.8.25和codeception 2.3.4