Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix tests on PHP 8.0 #9054

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

Merged
merged 6 commits into from
Sep 11, 2020
Merged

Fix tests on PHP 8.0 #9054

merged 6 commits into from
Sep 11, 2020

Conversation

GrahamCampbell
Copy link
Contributor

We need PHPUnit 9.3@dev (and its @dev stability dependencies), which include PHP 8.0 support, including sebastianbergmann/phpunit#4374 which fixes the issue with Match which is currently crashing composer's test suite on actions.

@GrahamCampbell
Copy link
Contributor Author

gahhhhhhh

image

@GrahamCampbell
Copy link
Contributor Author

Why is simple-phpunit ignoreing the environment variable...

@GrahamCampbell
Copy link
Contributor Author

Ok, got the tests to run now. Looks like there are some issues (mostly due to deprecated usage of phpunit causing real issues in 9.3.x or php 8.0 changing exception message text, from what I can see at a quick glance).

@Seldaek
Copy link
Member

Seldaek commented Jul 17, 2020

Yeah given the amount of deprecation warnings we had on phpunit 8, I was pretty sure it wouldn't run on 9.. I doubt this can be fixed without adding a huge amount of overrides for assertions and a huge mess.. So I am not sure what's best tbh, might be better to ignore php8 for now, and hopefully we can then in composer 2.1 target php8 more easily once we drop older php releases. I don't think it's realistic to support 5.3 all the way up given phpunit and phpunit-bridge restrictions.

@GrahamCampbell
Copy link
Contributor Author

The PHP ecosystem already relies on composer 2 working on PHP 8.0. I think we should try and update the test suite to work for both versions. I can try and work on it today... but we should also ask for help from others. If they wanna use composer on PHP 8.0, then they gotta put in their share. ;)

@Seldaek
Copy link
Member

Seldaek commented Jul 17, 2020

Well Composer works fine on php8, the test suite doesn't now because of phpunit and co.. If someone puts in the work and it's not creating an unreasonable mess in the test suite I'll happily take it in, but otherwise IMO it can wait, it runs well enough for now, and php8 isn't out yet.

@GrahamCampbell
Copy link
Contributor Author

Another approach would be to patch phpunit 8 to fix the match thing. ;)

@Seldaek
Copy link
Member

Seldaek commented Jul 17, 2020

That'd be much easier (for us) but I have a feeling @sebastianbergmann may not see it the same?

@GrahamCampbell
Copy link
Contributor Author

Yeh, I think so, and he has good reasons. For one, that might not be the only PHP 8.0 compatibility issue we run into, so the amount of stuff we might want backporting is potentially unbounded (it is certainly not the only PHP 8.0 compatibly issue within phpunit and its dependencies - there were a lot of other changes in particular around reflection of types).

@sebastianbergmann
Copy link

sebastianbergmann commented Jul 17, 2020

That'd be much easier (for us) but I have a feeling @sebastianbergmann may not see it the same?

I am sorry, but PHPUnit 8.5 and PHPUnit 9.2 will not be updated to support PHP 8.

nicolas-grekas added a commit to symfony/symfony that referenced this pull request Jul 23, 2020
This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

Require PHPUnit 9.3 on PHP 8

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| License       | MIT

The first version of PHPUnit to support PHP 8.0 is PHPUnit 9.3.

---

Depends on #37607. Related to composer/composer#9054.

Commits
-------

54b13c0 Require PHPUnit 9.3 on PHP 8
@GrahamCampbell GrahamCampbell marked this pull request as ready for review July 23, 2020 19:01
@GrahamCampbell
Copy link
Contributor Author

The tests are running now, at least, and there do seem to be some genuine issues (but also some issues due to using old phpunit methods).

run: |
composer require --no-update --dev symfony/phpunit-bridge:^5.1
composer config -g platform-check false
run: composer require --no-update --dev symfony/phpunit-bridge:5.1.*@dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why @dev, is that still needed at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed any more.


- name: "Update Symfony's PHPUnitBridge to latest available for the current PHP always as it is not really a dependency of the project"
run: "composer update ${{ env.COMPOSER_FLAGS }} symfony/phpunit-bridge"
run: "composer update ${{ env.COMPOSER_FLAGS }} symfony/phpunit-bridge --with-all-dependencies"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the new flag? It'd allow updating symfony components we rely on, I am not sure that's a good idea as it breaks the validity of locked dependencies builds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was needed because of old dependencies in the composer.lock, at the time.

@Seldaek
Copy link
Member

Seldaek commented Sep 8, 2020

Ok thanks for the feedback. Looks better now, will see what I can do about test failures later this week.

@Seldaek
Copy link
Member

Seldaek commented Sep 11, 2020

Ok we are down to one weird syntax error bug which I assume is phpunit-bridge based, and one actual failure due to php8 sorting order in TransactionTest.. so I'll merge this for now it's already improving things a lot. Thanks

@Seldaek Seldaek merged commit c1b0e6c into composer:master Sep 11, 2020
@GrahamCampbell GrahamCampbell deleted the php8 branch September 11, 2020 10:25
@GrahamCampbell
Copy link
Contributor Author

Thanks for finishing up this PR. 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants