-
Notifications
You must be signed in to change notification settings - Fork 27
Support PHPUnit 10 #70
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Looks like you are removing bits and pieces which ensured compatibility with PHPUnit 8.x. I very much doubt CI will pass on this PR. |
Indeed, there are behavioural changes. I believe there is little value in maintaining the different "original" error messages or exception types (if there even is such a thing, given this feature has been missing from PHPUnit for quite some time). It is not like someone is going to build functionality around what specifically happens when I don't see any incompatibility being introduced. The functionality can be used just like before, and the new error message should be just as clear as the one that was previously given. Tests passed locally. |
@spawnia Against which PHP/PHPUnit combinations ? |
@spawnia can you trigger the tests in your repo? |
I was able to run the tests in my fork and fixed a few minor issues that prevented CI from working, see https://github.com/spawnia/phpunit-arraysubset-asserts/pull/1. However, there is still a CI failure due to usage of a deprecated configuration schema, see https://github.com/spawnia/phpunit-arraysubset-asserts/actions/runs/4112652928/jobs/7097833112. I tried to fix this with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW: I've done a detailed review of this PR.
In my personal opinion, this PR should not be merged as-is. Please see the inline comments for more detailed feedback.
phpunit.xml.dist
Outdated
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
colors="true" | ||
verbose="true" | ||
<phpunit colors="true" | ||
failOnWarning="false" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
beStrictAboutChangesToGlobalState="true" | ||
convertErrorsToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertDeprecationsToExceptions="true" | ||
bootstrap="tests/bootstrap.php" | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unclear to me why the majority of these settings are being removed.
AFAICS, the only change needed is: xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.2/phpunit.xsd"
to indicate to PHPUnit the schema used (with 9.2 deliberately chosen as PHPUnit changes some thing in PHPUnit 9.3).
The original schema setting made it dependent on the Composer installed PHPUnit version, which makes the schema setting unstable if PHPUnit 10.0 would also be supported (as PHPUnit 10 made significant changes to the schema).
As for the other values - in part - being set to the default value used by PHPUnit: those defaults have changed for a lot of these across PHPUnit versions, which is why it is important to have these settings explicitly set to make sure tests are being run with the same configuration across PHPUnit versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reduced the PHPUnit configuration to be as minimal as possible in order to maximize compatbility between the different supported versions. Fortunately, the schema is not required and can simply be omitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reduced the PHPUnit configuration to be as minimal as possible in order to maximize compatbility between the different supported versions. Fortunately, the schema is not required and can simply be omitted.
Unfortunately, minimizing the config does the opposite as it does not allow for the tests to run with the same config across various PHPUnit versions.
As for the other values - in part - being set to the default value used by PHPUnit: those defaults have changed for a lot of these across PHPUnit versions, which is why it is important to have these settings explicitly set to make sure tests are being run with the same configuration across PHPUnit versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a suggestion on how to fix https://github.com/spawnia/phpunit-arraysubset-asserts/actions/runs/4466219397/jobs/7844126983 then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course 😉
I believe this can be fixed by running phpunit --migrate-configuration
in a separate CI step prior to running the actual tests.
The step should be run conditionally for PHPUnit 10 only.
You can grab the PHPUnit version with something like this:
- name: Grab PHPUnit version
id: phpunit_version
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT
... which allows you to check the version in a conditional step after that like so:
if: ${{ steps.phpunit_version.outputs.VERSION >= '10.0' }}
As a side-note: I find it weird that PHPUnit would exit with a non-zero exit code when it is only a warning from PHPUnit 10 itself and there are no test failures.
Might be worth opening an issue in the PHPUnit repo about this if there isn't one open already) as this is undesired and unexpected behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not get your suggestion to work, but found an alternative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been doing some testing with the --migrate-configuration
option and have found that unfortunately it does not sufficiently convert the configuration.
Most notably, the PHPUnit 10.x displayDetailsOn*
settings do not get set, while for a tool like this, which is used in the test pipeline by other projects, it is important to have access to information about deprecations in new PHP versions early.
For the PHPUnit Polyfills, I've now solved this by having a separate config file for PHPUnit 10.
If you'd like to see the implementation as an example, please have a look at: Yoast/PHPUnit-Polyfills#111
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed that in the upcoming PHPUnit 10.1.0 release there will be new failOnWarning
, failOnNotice
and failOnDeprecation
attributes. Those seem even better/more appropriate.
See:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should tackle 10.1 in another PR and continue this discussion there.
WDYT?
Any updates on this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's cater to @jrfnl comments and then clean up this branch. It has a lot of back-and-forth commits.
I'm happy to do that since I took so long to review it. I need some help understanding the Exception issue.
We no longer rely on the internal InvalidArgumentException from PHPUnit, but we still keep previous behavior for polyfill reasons. Co-authored-by: Benedikt Franke <benedikt.franke@mll.com>
Alright, I did some cleanup and adjusted the Exception checks. |
I also dropped the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rdohms for getting into this, I am fine with the changes you made and hope it can get merged soon.
I hope @jrfnl can review this soon. I'd love to keep using this package. |
@jrfnl any chance of reviewing and merging this PR? |
@jrfnl Is this package supported? |
Didn't see this getting merged soon - using the help of Github Copilot was able to rewrite our 4 lines using this and remove an additional package. |
Thanks for the merge, waiting for the release now. |
The changes in
ArraySubsetAsserts
were made due to the following test failures: