Nimut / testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests
GNU General Public License v2.0
52 stars 25 forks source link

First functional test database connection fails with Doctrine DBAL 2.13 #136

Closed mbrodala closed 3 years ago

mbrodala commented 3 years ago

I just did an update to TYPO3 10.4.16 which, among others, brings compatibility with Doctrine DBAL 2.13. Thus the latter was also updated to the latest 2.13 version.

Now the first of each functional tests fails to connect to the database. The database exists after the test so maybe something has changed in Doctrine which causes an earlier connection before the FunctionalTestCase setup.

First functional test run with Doctrine 2.13.1 ✖ ``` $ composer show doctrine/dbal | grep versions versions : * 2.13.1 $ mysql -h... -u... -p... -e "DROP DATABASE IF EXISTS typo3_functional_ft3d326a3;" $ rm -rf .../typo3temp/var/tests/functional-3d326a3/ $ phpunit --configuration phpunit-functional.xml --colors=always --filter SampleFunctionalTest PHPUnit Pretty Result Printer 0.29.3 by Codedungeon and contributors. ==> Configuration: /.../vendor/codedungeon/phpunit-result-printer/src/phpunit-printer.yml PHPUnit 7.5.20 by Sebastian Bergmann and contributors. Runtime: PHP 7.4.16 Configuration: /.../phpunit-functional.xml ==> SampleFunctionalTest ⚈ Time: 4.11 seconds, Memory: 12.00 MB ✖ There was 1 error: 1) Acme\Package\Tests\Functional\SampleFunctionalTest::test PHPUnit\Framework\Exception: PHP Warning: mysqli::real_connect(): (HY000/1049): Unknown database 'typo3_functional_ft3d326a3' in /.../vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php on line 86 ERRORS! Tests: 1, Assertions: 0, Errors: 1. ```
Subsequent functional test run with Doctrine 2.13.1 ✔ ``` $ phpunit --configuration phpunit-functional.xml --colors=always --filter SampleFunctionalTest PHPUnit Pretty Result Printer 0.29.3 by Codedungeon and contributors. ==> Configuration: /.../vendor/codedungeon/phpunit-result-printer/src/phpunit-printer.yml PHPUnit 7.5.20 by Sebastian Bergmann and contributors. Runtime: PHP 7.4.16 Configuration: /.../phpunit-functional.xml ==> SampleFunctionalTest ✔ Time: 2.28 seconds, Memory: 12.00 MB OK (1 test, 6 assertions) ```

Downgrading to Doctrine 2.11.x fixes the problem:

First functional test run with Doctrine 2.11.3 ✔ ``` $ composer show doctrine/dbal | grep versions versions : * 2.11.3 $ mysql -h... -u... -p... -e "DROP DATABASE IF EXISTS typo3_functional_ft3d326a3;" $ rm -rf .../typo3temp/var/tests/functional-3d326a3/ $ phpunit --configuration phpunit-functional.xml --colors=always --filter SampleFunctionalTest PHPUnit Pretty Result Printer 0.29.3 by Codedungeon and contributors. ==> Configuration: /.../vendor/codedungeon/phpunit-result-printer/src/phpunit-printer.yml PHPUnit 7.5.20 by Sebastian Bergmann and contributors. Runtime: PHP 7.4.16 Configuration: /.../phpunit-functional.xml ==> SampleFunctionalTest ✔ Time: 2.28 seconds, Memory: 12.00 MB OK (1 test, 6 assertions) ```
mbrodala commented 3 years ago

Public example: https://github.com/pagemachine/typo3-flat-urls/pull/40/checks?check_run_id=2556292024

image

Notice how the first of all tests for a SUT fails.

AnatoliZich commented 3 years ago

I can confirm this, even though im using the typo3/testing-framework. Downgrading doctrine/dbal to 2.11.3 fixes the problem.

tomasnorre commented 3 years ago

I can confirm this + the downgrade to 2.11.x

IchHabRecht commented 3 years ago

After some investigations, the problem occures due to changes in the doctrine/dbal project. It is already fixed in the latest development branch (https://github.com/doctrine/dbal/commit/b9b30b2eb0596c465418964c032b3f208817adc7#diff-e109793061ef1816d2ddf43ca20f451a9f79adf03e4c15ddf9efd82b8fd81dc8) and should be fixed with the next doctrine/dbal release. The testing-framework needs to mark doctrine versions 2.13.0 and 2.13.1 as conflict.

mbrodala commented 3 years ago

Yes, thanks for the interim fix!