dmaicher / doctrine-test-bundle

Symfony bundle to isolate your app's doctrine database tests and improve the test performance
MIT License
1.08k stars 60 forks source link

Add doctrine/dbal version check to avoid using deprecated ExceptionCo… #147

Closed sidz closed 3 years ago

sidz commented 3 years ago

This PR:

This fix works for the lowest supported version (2.9.3) as well.

related issue: https://github.com/dmaicher/doctrine-test-bundle/issues/129

dmaicher commented 3 years ago

This breaks when using doctrine/dbal 2.12.0:

vendor/bin/phpunit -c tests/ tests/
PHP Fatal error:  Declaration of DAMA\DoctrineTestBundle\Doctrine\DBAL\AbstractStaticDriverV3::connect(array $params) must be compatible with Doctrine\DBAL\Driver::connect(array $params, $username = NULL, $password = NULL, array $driverOptions = Array) in /var/www/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/AbstractStaticDriverV3.php on line 17

Fatal error: Declaration of DAMA\DoctrineTestBundle\Doctrine\DBAL\AbstractStaticDriverV3::connect(array $params) must be compatible with Doctrine\DBAL\Driver::connect(array $params, $username = NULL, $password = NULL, array $driverOptions = Array) in /var/www/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/AbstractStaticDriverV3.php on line 17

In AbstractStaticDriverV3.php line 17:

  [Symfony\Component\ErrorHandler\Error\FatalError]                                                                                                                                                               
  Compile Error: Declaration of DAMA\DoctrineTestBundle\Doctrine\DBAL\AbstractStaticDriverV3::connect(array $params) must be compatible with Doctrine\DBAL\Driver::connect(array $params, $username = NULL, $pas  
  sword = NULL, array $driverOptions = Array)                                                                                                                                                                     

Exception trace:
  at /var/www/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/AbstractStaticDriverV3.php:17

doctrine:database:drop [-s|--shard SHARD] [-c|--connection [CONNECTION]] [--if-exists] [-f|--force]

I also fail to see what exactly this fixes? on dbal < 3 we need to use the class extending ExceptionConverterDriver as otherwise it simply does not work correctly. So we need to load the deprecated interface anyway?

sidz commented 3 years ago

wondered why CI not fail :)

I also fail to see what exactly this fixes? on dbal < 3 we need to use the class extending ExceptionConverterDriver as otherwise it simply does not work correctly.

Probably I missed smth. I'll take a look more attentively and back with solution.

sidz commented 3 years ago

Looks like I was too optimistic :)

I'm going to close this PR.