-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Tests: make test suite compatible with PHPUnit 10.x #483
Merged
jrfnl
merged 13 commits into
develop
from
feature/make-tests-compatible-with-phpunit-10
Jun 12, 2023
Merged
Tests: make test suite compatible with PHPUnit 10.x #483
jrfnl
merged 13 commits into
develop
from
feature/make-tests-compatible-with-phpunit-10
Jun 12, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A PHPUnit 10 compatible version of the PHPUnit Polyfills has been released, so let's start using it. Ref: * https://github.com/Yoast/PHPUnit-Polyfills/releases/tag/2.0.0
As the available traits are different between the 1.x and 2.x versions of the PHPUnit Polyfills, two different class definitions are needed. This change uses the available PHPUnit Polyfills version number to load the correct class.
As of PHPUnit 10, data providers are (again) expected to be `static` methods. This updates the test suite to respect that. Includes removing the use of `$this` from select data providers. Refs: * sebastianbergmann/phpunit@9caafe2 * sebastianbergmann/phpunit 5100
…patibility with PHPUnit 10
…se::getName()` method ... in favour of just using a randomly generated ID for the cache.
…back()` method PHPUnit 10.0 removed the `TestCase::setOutputCallback()` method without replacement. Refs: * sebastianbergmann/phpunit 5319
... to provide a work-around for the removal of the `InvocationMocker->withConsecutive()` method, which was removed without replacement in PHPUnit 10.0. Refs: * sebastianbergmann/phpunit 4026 * sebastianbergmann/phpunit 4255 * sebastianbergmann/phpunit 4564
…WithConsecutiveArgs` helper
…::setMethods()` removal Please note: * The `getMockBuilder()` class is also deprecated now, so replacing with another method call on the `MockBuilder` class will only work in the short/medium term and in a future iteration, this will have to be refactored again. * Also the `getMockForAbstractClass method is also deprecated and expected to be removed in PHPUnit 12. Refs: * sebastianbergmann/phpunit 3687#issuecomment-492537584 * sebastianbergmann/phpunit 3770 * sebastianbergmann/phpunit 3769 * sebastianbergmann/phpunit 4775
PHPUnit 10 makes significant changes to the configuration file. While there is a `--migrate-configuration` option available in PHPUnit, that doesn't get us a well enough converted configuration file, so instead use a separate `phpunit10.xml.dist` file for running the tests on PHPUnit 10 with an optimal configuration. Includes * Adding separate scripts to the `composer.json` file to make this more obvious for contributors. * Updating the GH Actions workflows to take the new configuration file into account when appropriate. * Selectively not using the `--repeat` option, which was [removed without replacement](sebastianbergmann/phpunit#5174) in PHPUnit 10.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Composer: update the PHPUnit Polyfills
A PHPUnit 10 compatible version of the PHPUnit Polyfills has been released, so let's start using it.
Ref:
Tests/PolyfilledTestCase: make compatible with PHPUnit Polyfills 2.x
As the available traits are different between the 1.x and 2.x versions of the PHPUnit Polyfills, two different class definitions are needed.
This change uses the available PHPUnit Polyfills version number to load the correct class.
Tests/ConfigDataTest: switch to the PHPUnit Polyfills TestCase
Tests: make dataproviders static
As of PHPUnit 10, data providers are (again) expected to be
static
methods.This updates the test suite to respect that.
Includes removing the use of
$this
from select data providers.Refs:
Tests/SpacerFixer: make data providers static for compatibility with PHPUnit 10
Tests/InterpolatedVariablesTest: make data providers static for compatibility with PHPUnit 10
Tests/[NoFile]Cache/SetTest: remove use of the remove PHPUnit
TestCase::getName()
method... in favour of just using a randomly generated ID for the cache.
Tests/HasNewLineSupportTest: work round removal of the
setOutputCallback()
methodPHPUnit 10.0 removed the
TestCase::setOutputCallback()
method without replacement.Refs:
Tests/AbstractArrayDeclarationSniffTest: various tweaks and improvements
Tests: add new ExpectWithConsecutiveArgs helper trait
... to provide a work-around for the removal of the
InvocationMocker->withConsecutive()
method, which was removed without replacement in PHPUnit 10.0.Refs:
Tests/AbstractArrayDeclarationSniffTest: implement use of the
ExpectWithConsecutiveArgs
helperTests/AbstractArrayDeclarationSniffTest: work around for
MockBuilder::setMethods()
removalPlease note:
getMockBuilder()
class is also deprecated now, so replacing with another method call on theMockBuilder
class will only work in the short/medium term and in a future iteration, this will have to be refactored again.Refs:
PHPUnit: add separate configuration for PHPUnit 10
PHPUnit 10 makes significant changes to the configuration file.
While there is a
--migrate-configuration
option available in PHPUnit, that doesn't get us a well enough converted configuration file, so instead use a separatephpunit10.xml.dist
file for running the tests on PHPUnit 10 with an optimal configuration.Includes
composer.json
file to make this more obvious for contributors.--repeat
option, which was removed without replacement in PHPUnit 10.