mercredi 2 août 2017

Codeception acceptance tests with Symfonys MasterSlaveConnection throws Exception

I'm using codeception (acceptance tests) in combination with the Symfony and Doctrine2 modules.

When I configure Symfony to use a single database connection, everything works fine and my tests finish. But as soon as I add database slave connections, the following exception appears and the test failes:

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

I cannot understand how this error arises, because in the stated file (MasterSlaveConnection.php) the class is clearly extended from Connection, in which the property $_conn is defined.

Can someone help me with that? Is this a bug and I should open up a bug report on the codeception github page? Or am I doing something wrong? Thank you in advance!


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 with single database configuration:

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 with multiple database configuration:

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%"

I'm using symfony 2.8.25 and codeception 2.3.4

Aucun commentaire:

Enregistrer un commentaire