Skip to content
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

Upgrade PHPUnit for php 8 #37564

Closed
derrabus opened this issue Jul 12, 2020 · 2 comments
Closed

Upgrade PHPUnit for php 8 #37564

derrabus opened this issue Jul 12, 2020 · 2 comments

Comments

@derrabus
Copy link
Member

derrabus commented Jul 12, 2020

Symfony version(s) affected: 3.4, 4.4, 5.1, 5.2

Description
We are currently using PHPUnit 8.3 to run the test suite on the most recent php versions. This has worked fine so far, but a recent change to php's master branch rendered that version incompatible with php 8, see sebastianbergmann/phpunit#4373. Because of that, our Travis builds on php8 have become useless.

How to reproduce
Run the test suite on php 8.

Possible Solution
A) The patch is fairly easy and could be applied to PHPUnit 8. Please, let's not do that.
B) Make the test suite compatible with PHPUnit 9 and use 9.3-dev on php 8.

Additional context
https://travis-ci.org/github/symfony/symfony/jobs/707437283

@derrabus
Copy link
Member Author

This is not solved yet because we still use PHPUnit 8.3 to run our own test suite. Please reopen.

@xabbuh xabbuh reopened this Jul 23, 2020
@derrabus
Copy link
Member Author

Blocker: #37637

nicolas-grekas added a commit that referenced this issue Jul 23, 2020
This PR was merged into the 3.4 branch.

Discussion
----------

[3.4] Fix PHPUnit 8.5 deprecations

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | #37564
| License       | MIT
| Doc PR        | N/A

PHPUnit 8.5 introduced several deprecations. Addressing them will allow us to upgrade to PHPUnit 9.

Commits
-------

ec525e6 Fix PHPUnit 8.5 deprecations.
fabpot added a commit that referenced this issue Aug 8, 2020
…s (derrabus)

This PR was merged into the 5.1 branch.

Discussion
----------

[String] We cannot have a "provides" function in test cases

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Part of #37564
| License       | MIT
| Doc PR        | N/A

Because of a change in PHPUnit 9.3 (see sebastianbergmann/phpunit#3936), we cannot have define a method named `provides` in test cases. And since php is case-insensitive regarding method calls, the method `provideS` used by the String component's `FunctionTest` will cause a fatal error. I have renamed it to work around that issue.

cc @fancyweb

Commits
-------

46e2a0c [String] We cannot have a "provides" function in test cases.
fabpot added a commit that referenced this issue Aug 9, 2020
….3 (derrabus)

This PR was merged into the 3.4 branch.

Discussion
----------

The PHPUnit\Util\XML class has been removed in PHPUnit 9.3

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Part of #37564
| License       | MIT
| Doc PR        | N/A

`PHPUnit\Util\XML`, an internal PHPUnit class, is used in a couple of tests. Those tests fail on PHPUnit 9.3 because that class has been removed. This PR fixes those tests by using the new class if it's available.

If this is too much C&P, we could consider having PhpUnitBridge polyfill this call.

Commits
-------

8b801c1 The PHPUnit\Util\XML class has been removed in PHPUnit 9.3.
fabpot added a commit that referenced this issue Aug 9, 2020
This PR was squashed before being merged into the 3.4 branch.

Discussion
----------

Modernized deprecated PHPUnit assertion calls

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Part of #37564
| License       | MIT
| Doc PR        | N/A

Some assertions have been renamed in PHPUnit 9. PhpUnitBridge should already have polyfills in place for those methods, so it should be save to use them.

Commits
-------

ab417f7 Modernized deprecated PHPUnit assertion calls
fabpot added a commit that referenced this issue Aug 10, 2020
…derrabus)

This PR was merged into the 3.4 branch.

Discussion
----------

PHPUnit's assertContains() performs strict comparisons

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Part of #37564
| License       | MIT
| Doc PR        | N/A

In PHPUnit 9.3, `assertContains()` performs a strict comparison which causes a few test failures in our test suite. This PR should fix them.

Commits
-------

9f4dec5 PHPUnit's assertContains() performs strict comparisons now.
fabpot added a commit that referenced this issue Aug 12, 2020
This PR was merged into the 3.4 branch.

Discussion
----------

Use PHPUnit 9.3 on php 8

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Part of #37564
| License       | MIT
| Doc PR        | N/A

Our CI for PHP 8 is currently a blind spot, mainly because the PHPUnit version 8.3 that we use for the test suite is incompatible with php 8. This PR changes the PHPUnit version used on Travis for php 8 to PHPUnit 9.3.

Our test suite might not be 100% compatible with that new PHPUnit release yet, but this change should allow us to run most tests on php 8 again and enable us to iteratively migrate to PHPUnit 9.3.

Commits
-------

d642d85 Use PHPUnit 9.3 on php 8.
fabpot added a commit that referenced this issue Sep 5, 2020
…rait for PHPUnit 9.3 (sanmai, derrabus)

This PR was merged into the 3.4 branch.

Discussion
----------

[PhpUnitBridge] Adjust output parsing of CoverageListenerTrait for PHPUnit 9.3

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #37637, #37564
| License       | MIT
| Doc PR        | N/A

This PR makes `CoverageListenerTrait` pass with PHPUnit 9.3. It contains a backport of #38054.

The problem that is addressed here is that a one of the fixture classes is now included in the output despite having a coverage of zero. The test now accepts both cases:

* The class is omitted from the output
* The class appears with 0.00% coverage.

Commits
-------

a3831dc [PhpUnitBridge] Adjust output parsing for PHPUnit 9.3.
99c98bd [PhpUnitBridge] CoverageListenerTrait update for PHPUnit 8.5/9.x
fabpot added a commit that referenced this issue Sep 7, 2020
…bus)

This PR was merged into the 4.4 branch.

Discussion
----------

Don't call createMock with an array of interfaces

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #37564
| License       | MIT
| Doc PR        | N/A

PHPUnit 8 allows us to pass an array of interfaces to `createMock()`. The result was a mock object that implemented all of the given interfaces. This feature has sadly been removed (see sebastianbergmann/phpunit#3955), which forces us to create dummy classes that can be mocked instead. I've done this already on the 3.4 branch with #37566.

This PR fixes all affected tests (that I could find) on the 4.4 branch.

Commits
-------

a8e762d Don't call createMock with an array of interfaces.
fabpot added a commit that referenced this issue Sep 7, 2020
This PR was merged into the 4.4 branch.

Discussion
----------

[WebProfilerBundle] Fix Tests for PHPUnit 9.3

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #37564
| License       | MIT
| Doc PR        | N/A

PHPUnit's `logicalXor()` creates an XOR operation for one or multiple constraints. It expects the operands for that operation to be passed as variadic arguments, but this particullar test passes them in a single array.

This somewhat works on PHPUnit 8, but fails on PHPUnit 9. This PR fixes the failing test.

Commits
-------

f290b97 [WebProfilerBundle] Fix Tests on PHPUnit 9.3.
fabpot added a commit that referenced this issue Sep 7, 2020
This PR was merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle] Fix Tests on PHPUnit 9.3

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #37564
| License       | MIT
| Doc PR        | N/A

When joining two constraints with a `LogicalAnd`, PHPUnit will generate a failure message where the message omitted by the first constraint will be wrapped in parenthesis. I'm using a regular expression now, so we can support both variants.

Commits
-------

8bc36d7 [FrameworkBundle] Fix Tests on PHPUnit 9.3.
chalasr added a commit that referenced this issue Sep 7, 2020
…erfaces (derrabus)

This PR was merged into the 5.1 branch.

Discussion
----------

[SecurityHttp] Don't call createMock() with multiple interfaces

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #37564
| License       | MIT
| Doc PR        | N/A

Continuation of #38079 for the 5.1 branch.

Commits
-------

028ec0c [SecurityHttp] Don't call createMock() with multiple interfaces.
fabpot added a commit that referenced this issue Sep 13, 2020
This PR was submitted for the master branch but it was merged into the 4.4 branch instead.

Discussion
----------

[PhpUnitBridge] Internal classes are not legacy

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #37564
| License       | MIT
| Doc PR        | N/A

This change works around the issue that we can observe in the failed Travis build of #38103.

We must not call PHPUnit's internal `Test::getGroups()` method with a built-in class, otherwise we will run into a TypeError. This won't be fixed on PHPUnit's side, so we need to prevent that call. Our DeprecationErrorHander might run into this case if a deprecation is triggered while autoloading a class.

And forgive me, I've had a really hard time trying to craft a test case for that. 🙈

Commits
-------

7d55e0c Internal classes are not legacy.
@fabpot fabpot closed this as completed Sep 14, 2020
fabpot added a commit that referenced this issue Sep 14, 2020
…errabus)

This PR was merged into the 3.4 branch.

Discussion
----------

Upgrade PHPUnit to 8.5 (php 7.2) and 9.3 (php >= 7.3)

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes/no
| New feature?  | no
| Deprecations? | no
| Tickets       | #37564
| License       | MIT
| Doc PR        | N/A

Our test suite on the 3.4 branch should be compatible with more recent versions of PHPUnit now. In order to make sure that it stays that way, I'm proposing to bump PHPUnit to 8.5 for the php 7.2 job and 9.3 for the php 7.3 and 7.4 jobs.

Commits
-------

ff47516 Upgrade PHPUnit to 8.5 (php 7.2) and 9.3 (php >= 7.3).
fabpot added a commit that referenced this issue Sep 17, 2020
…errabus)

This PR was merged into the 4.4 branch.

Discussion
----------

Upgrade PHPUnit to 8.5 (php 7.2) and 9.3 (php >= 7.3)

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | #37564
| License       | MIT
| Doc PR        | N/A

This is #38103 on the 4.4 branch.

Commits
-------

73647e5 Upgrade PHPUnit to 8.5 (php 7.2) and 9.3 (php >= 7.3).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants