Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support PHPUnit 10 #70

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
rdohms merged 1 commit into rdohms:master from spawnia:support-phpunit-10
Jun 2, 2023
Merged

Support PHPUnit 10 #70

rdohms merged 1 commit into rdohms:master from spawnia:support-phpunit-10
Jun 2, 2023

Conversation

Copy link
Contributor

@spawnia spawnia commented Feb 3, 2023

The changes in ArraySubsetAsserts were made due to the following test failures:

There were 2 failures:
1) DMS\PHPUnitExtensions\ArraySubset\Tests\Unit\AssertTest::testAssertArraySubsetThrowsExceptionForInvalidSubsetArgument
Failed asserting that exception of type "Error" matches expected exception "PHPUnit\Framework\Exception". Message was: "Call to undefined method PHPUnit\Framework\InvalidArgumentException::create()" at
/home/bfranke/projects/phpunit-arraysubset-asserts/src/ArraySubsetAsserts.php:35
/home/bfranke/projects/phpunit-arraysubset-asserts/tests/Unit/AssertTest.php:32
.
2) DMS\PHPUnitExtensions\ArraySubset\Tests\Unit\AssertTest::testAssertArraySubsetThrowsExceptionForInvalidArrayArgument
Failed asserting that exception of type "Error" matches expected exception "PHPUnit\Framework\Exception". Message was: "Call to undefined method PHPUnit\Framework\InvalidArgumentException::create()" at
/home/bfranke/projects/phpunit-arraysubset-asserts/src/ArraySubsetAsserts.php:51
/home/bfranke/projects/phpunit-arraysubset-asserts/tests/Unit/AssertTest.php:38

davidbarker, cheack, senaranya, Bloemendaal, jmarcher, dmitryuk, ksaveras, and sidz reacted with thumbs up emoji dmnlk, mattvb91, tancou, and silverjason reacted with heart emoji derrabus, xbbshampoo, and silverjason reacted with rocket emoji
spawnia added a commit to webonyx/graphql-php that referenced this pull request Feb 3, 2023
Copy link
Collaborator

jrfnl commented Feb 4, 2023

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.

Copy link
Contributor Author

spawnia commented Feb 4, 2023

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 assertArraySubset() is misused in a certain way.

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.

Copy link
Collaborator

jrfnl commented Feb 4, 2023

Tests passed locally.

@spawnia Against which PHP/PHPUnit combinations ?

Copy link

mattvb91 commented Feb 7, 2023

@spawnia can you trigger the tests in your repo?

Copy link
Contributor Author

spawnia commented Feb 7, 2023

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 b5299be (#70), but apparently this did not help. I was able to fix the issue by basically miniziming the PHPUnit configuration to avoid usage of incompatible elements (e.g. whitelist was changed to include): 97c61a5 (#70).

mattvb91 reacted with thumbs up emoji mattvb91 reacted with hooray emoji

@rdohms rdohms requested a review from jrfnl February 14, 2023 12:56
Copy link

@jrfnl @rdohms any idea what is needed to get this in? Thanks

Copy link
Collaborator

jrfnl commented Feb 20, 2023

@jrfnl @rdohms any idea what is needed to get this in? Thanks

Time for the maintainers to do a proper review. I'll do one once I'm back from my break, but that will still be a couple more weeks.

mattvb91 reacted with thumbs up emoji

Copy link
Collaborator

@jrfnl jrfnl left a 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.

Comment on lines 3 to 15
<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"
>
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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

Copy link
Collaborator

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:

Copy link
Owner

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?

Copy link

hilioski commented Apr 4, 2023

Any updates on this PR?

silverjason, cheack, and alarai reacted with thumbs up emoji spawnia and elliotbruneel reacted with thumbs down emoji rdohms reacted with eyes emoji

Copy link
Owner

@rdohms rdohms left a 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>
Copy link
Owner

rdohms commented Apr 22, 2023

Alright, I did some cleanup and adjusted the Exception checks.
It should be all good now; @jrfnl can you re-review to see if I missed anything?

spawnia reacted with thumbs up emoji

@rdohms rdohms requested a review from jrfnl April 22, 2023 22:23
Copy link
Owner

rdohms commented Apr 22, 2023

I also dropped the composer.lock once and for all.

jrfnl and derrabus reacted with thumbs up emoji

Copy link
Contributor Author

@spawnia spawnia left a 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.

Copy link

I hope @jrfnl can review this soon. I'd love to keep using this package.

senaranya and michaelarnauts reacted with thumbs up emoji

Copy link

slaff commented May 15, 2023

@jrfnl any chance of reviewing and merging this PR?

senaranya, dmitryuk, and michaelarnauts reacted with thumbs up emoji

Copy link

@jrfnl Is this package supported?

senaranya, alexw23, and dmitryuk reacted with thumbs up emoji

Copy link

alexw23 commented May 25, 2023
edited
Loading

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.

senaranya and rexs123 reacted with rocket emoji

@rdohms rdohms merged commit aa6b9e8 into rdohms:master Jun 2, 2023
@spawnia spawnia deleted the support-phpunit-10 branch June 5, 2023 07:27
Copy link
Contributor Author

spawnia commented Jun 5, 2023

Thanks for the merge, waiting for the release now.

mattvb91 reacted with thumbs up emoji

@rdohms rdohms added this to the v0.5.0 milestone Jun 7, 2023
@rdohms rdohms added the Feature New feature or request label Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@rdohms rdohms rdohms approved these changes

@jrfnl jrfnl Awaiting requested review from jrfnl

Assignees
No one assigned
Labels
dependencies Feature New feature or request
Projects
None yet
Milestone
v0.5.0
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /