symfony: [PhpUnitBridge] PHPUnit 8 incompatibility
Symfony version(s) affected: 4.2.x (but probably all PHP<7.0 compatible versions too)
Description
Using the symfony/testpack, symfony/phpunit-bridge and setting the phpunit version on 8.0. When creating a test which extends Symfony\Bundle\FrameworkBundle\Test\KernelTestCase it will throw the following error:
PHP Fatal error: Declaration of Symfony\Bundle\FrameworkBundle\Test\KernelTestCase::tearDown() must be compatible with PHPUnit\Framework\TestCase::tearDown(): void in /projects/phpunit-8/vendor/symfony/framework-bundle/Test/KernelTestCase.php on line 24
How to reproduce
https://github.com/evertharmeling/symfony-phpunit-8
Using the ‘reproducer’ project:
- Run
composer installin project root. - Run
vendor/bin/simple-phpunitin project root.
Possible Solution
- Restricting the
phpunit/phpunitversion to<8.0
Additional context
Somewhat related https://github.com/symfony/symfony/issues/14736. Because this could solve for support on phpunit >=8.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 14
- Comments: 22 (13 by maintainers)
Commits related to this issue
- bug #30084 Fix KernelTestCase compatibility for PhpUnit 8 (alexander-schranz) This PR was merged into the 3.4 branch. Discussion ---------- Fix KernelTestCase compatibility for PhpUnit 8 | Q ... — committed to symfony/symfony by nicolas-grekas 5 years ago
- compatibnility with phpunit8 See https://github.com/symfony/symfony/issues/30071 — committed to garak/symfony by garak 5 years ago
- compatibnility with phpunit8 See https://github.com/symfony/symfony/issues/30071 — committed to garak/symfony by garak 5 years ago
- bug #30474 compatibility with phpunit8 (garak) This PR was merged into the 3.4 branch. Discussion ---------- compatibility with phpunit8 This basically adds the same phpunit8 compatibility layer a... — committed to symfony/symfony by fabpot 5 years ago
@StevenCarre when using
PhpUnitBridgewith https://github.com/evertharmeling/symfony-phpunit-8/blob/master/phpunit.xml.dist#L14What about other Symfony tests? For example, https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php is still missing the
voidreturn type, so extending it to test a form is not working. Doing a quick search (just agrep -r 'function setUp()' vendor/symfony/ | grep Test), I can find 208 occurrences ofsetUpmethod, all withoutvoidreturn type.We regularly merge lower branches up into branches for all still maintained Symfony versions. So the bugfix will also be part of the next 4.2 patch release.