Skip to content

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Apr 15, 2025

Description

Tests: the unit tests now require PHPUnit 8+

Tests: remove work-arounds for expecting exceptions

AbstractFilterTestCase: remove work-around for change to PHPUnit getMockBuilder()

Tests: remove work-arounds for setup/teardown methods

As of PHPUnit 8, the setUpBeforeClass(), setUp(), tearDown() and tearDownAfterClass() method were required to have a void return type declaration.

This could previously not be applied as the test suite had to stay compatible with PHP < 7.2, so as a work-around, the @beforeClass, @before, @after and @afterClass annotations were used for these setup/teardown methods.

As support for PHPUnit < 8 has now been dropped, this work-around is no longer needed and the methods can use the more customary PHPUnit fixture method signature again.

Tests: remove work-arounds for @requires tags

PHPUnit supports the @requires OSFAMILY ... syntax since PHPUnit 7.

As this new type doesn't allow for negation, the @requires OS ^(?!WIN).* for the PrepareForOutputTest::testPrepareForOutput() method needs to remain as it should run when not on Windows.

Tests: use assertIs[Type] assertions

These assertions were introduced in PHPUnit 7.5.0 to replace the assertInternalType() assertion method.
To not have PHPUnit version toggles everywhere, the assertions used native PHP in combination with assertTrue() for now.

As support for PHPUnit < 8 has been dropped though, we can now use the PHPUnit native assertIs[Type]() assertions.

Suggested changelog entry

Changed:
The minimum required PHPUnit version for the test framework has changed from 4.0 to 8.0.

Related issues/external references

Related to #25

gsherwood and others added 6 commits April 15, 2025 12:37
As of PHPUnit 8, the `setUpBeforeClass()`, `setUp()`, `tearDown()` and `tearDownAfterClass()` method were required to have a `void` return type declaration.

This could previously not be applied as the test suite had to stay compatible with PHP < 7.2, so as a work-around, the `@beforeClass`, `@before`, `@after` and `@afterClass` annotations were used for these setup/teardown methods.

As support for PHPUnit < 8 has now been dropped, this work-around is no longer needed and the methods can use the more customary PHPUnit fixture method signature again.

Co-authored-by: Greg Sherwood <[email protected]>
PHPUnit supports the `@requires OSFAMILY ...` syntax since PHPUnit 7.

As this new type doesn't allow for negation, the `@requires     OS ^(?!WIN).*` for the `PrepareForOutputTest::testPrepareForOutput()` method needs to remain as it should run when _not_ on Windows.
These assertions were introduced in PHPUnit 7.5.0 to replace the `assertInternalType()` assertion method.
To not have PHPUnit version toggles everywhere, the assertions used native PHP in combination with `assertTrue()` for now.

As support for PHPUnit < 8 has been dropped though, we can now use the PHPUnit native `assertIs[Type]()` assertions.
@jrfnl jrfnl merged commit be84dd8 into 4.x Apr 15, 2025
54 checks passed
@jrfnl jrfnl deleted the phpcs-4.0/feature/tests-drop-support-phpunit-lt-8 branch April 15, 2025 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants