New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PhpUnitBridge] PHPUnit 8 incompatibility #30071

evertharmeling opened this Issue Feb 4, 2019 · 5 comments


None yet
4 participants
Copy link

evertharmeling commented Feb 4, 2019

Symfony version(s) affected: 4.2.x (but probably all PHP<7.0 compatible versions too)

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

Using the 'reproducer' project:

  • Run composer install in project root.
  • Run vendor/bin/simple-phpunit in project root.

Possible Solution

  • Restricting the phpunit/phpunit version to <8.0

Additional context

Somewhat related #14736. Because this could solve for support on phpunit >=8.0


This comment has been minimized.

Copy link

alexander-schranz commented Feb 5, 2019

Another solution could be using class_alias: see #30084

nicolas-grekas added a commit that referenced this issue Feb 8, 2019

bug #30084 Fix KernelTestCase compatibility for PhpUnit 8 (alexander-…

This PR was merged into the 3.4 branch.


Fix KernelTestCase compatibility for PhpUnit 8

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  |no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30071
| License       | MIT
| Doc PR        |

As the PhpUnit 8 Testcase has different return types as PhpUnit 7 there need to be 2 different classes to support both PhpUnit 8 and PhpUnit 7. With a class alias we can then change which version is used based on the PhpUnit Version constant. The fix is a little bit hacky but to support different major versions I see no other way.

Not sure as we can't upgrade symfony/symfony to PhpUnit 8 how we can create a TestCase for this change.


83a56a0 Fix phpunit 8 compatibility

This comment has been minimized.

Copy link
Contributor Author

evertharmeling commented Feb 18, 2019


This comment has been minimized.

Copy link

xabbuh commented Feb 18, 2019

I think we can close here now that the related PRs were merged.

@xabbuh xabbuh closed this Feb 18, 2019


This comment has been minimized.

Copy link

mente commented Feb 19, 2019

Wasn't #30124 merged only into 3.4 branch only? This bug report is about 4.2


This comment has been minimized.

Copy link

xabbuh commented Feb 19, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment