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

Closed
evertharmeling opened this Issue Feb 4, 2019 · 5 comments

Comments

Projects
None yet
4 participants
@evertharmeling
Copy link
Contributor

evertharmeling commented Feb 4, 2019

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

@alexander-schranz

This comment has been minimized.

Copy link
Contributor

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-…
…schranz)

This PR was merged into the 3.4 branch.

Discussion
----------

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.

Commits
-------

83a56a0 Fix phpunit 8 compatibility
@evertharmeling

This comment has been minimized.

Copy link
Contributor Author

evertharmeling commented Feb 18, 2019

@xabbuh

This comment has been minimized.

Copy link
Member

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

@mente

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

@xabbuh

This comment has been minimized.

Copy link
Member

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