Skip to content

Commit

Permalink
Drop support for PHPUnit < 7.5 [6]
Browse files Browse the repository at this point in the history
Even though the TestListener implementation is not (yet) compatible with PHPUnit 10 (nor 11 or 12), we should still drop support for PHPUnit < 7.5 from the existing implementation.

This includes:
* Dropping support for the PHPUnit 6 specific implementation of the TestListener.
* Removing the semi-duplicate test fixture classes for PHPUnit < 7, as well as removing the test helper method containing the toggle for which fixture to use.
* Updating the documentation in the README.
  • Loading branch information
jrfnl committed Jan 14, 2025
1 parent 01739dd commit 1dcba37
Show file tree
Hide file tree
Showing 19 changed files with 29 additions and 384 deletions.
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,11 @@ class MyTest extends XTestCase {

> :warning: **Important** :warning:
>
> The TestListener polyfill in PHPUnit Polyfills 2.0/3.0 is [not (yet) compatible with PHPUnit 10.x/11.x][polyfill-ticket].
> The TestListener polyfill in PHPUnit Polyfills 2.0/3.0/4.0 is [not (yet) compatible with PHPUnit 10.x/11.x/12.x][polyfill-ticket].
>
> If you need the TestListener polyfill, it is recommended to stay on the PHPUnit Polyfills 1.x series for the time being and to watch and upvote the [related ticket][polyfill-ticket].
>
> The below documentation is for the PHPUnit 6.x-9.x TestListener polyfill implementation.
> The below documentation is for the PHPUnit 7.x-9.x TestListener polyfill implementation.
[polyfill-ticket]: https://github.com/Yoast/PHPUnit-Polyfills/issues/128

Expand All @@ -567,9 +567,7 @@ Additionally, the use of the TestListener principle has been deprecated in PHPUn

> Note: while deprecated in PHPUnit 7, the TestListener interface has not yet been removed and is still supported in PHPUnit 9.x.
If your test suite does not need to support PHPUnit < 7, it is strongly recommended to use the TestRunner hook interfaces extensions instead.

However, for test suites that still need to support PHPUnit 6 or lower, implementing the `TestListener` interface is the only viable option.
It is recommended to use the TestRunner hook interfaces extensions instead.

#### `Yoast\PHPUnitPolyfills\TestListeners\TestListenerDefaultImplementation`

Expand All @@ -592,10 +590,6 @@ Similar to the `TestCase` implementation, snake_case methods without type declar

Implementations of the `TestListener` interface may be using any of the following patterns:
```php
// PHPUnit 6.
class MyTestListener extends \PHPUnit\Framework\BaseTestListener {}

// PHPUnit 7+.
class MyTestListener implements \PHPUnit\Framework\TestListener {
use \PHPUnit\Framework\TestListenerDefaultImplementation;
}
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ parameters:
# The traits are functionality, but not used by the package itself. Can't be helped.
-
identifier: trait.unused
path: src/TestListeners/TestListenerDefaultImplementationPHPUnit6.php
path: src/TestListeners/TestListenerDefaultImplementationPHPUnitGte7.php
-
identifier: trait.unused
path: src/TestListeners/TestListenerSnakeCaseMethods.php
Expand Down
7 changes: 0 additions & 7 deletions phpunitpolyfills-autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,6 @@ public static function loadTestCase() {
* @return void
*/
public static function loadTestListenerDefaultImplementation() {
if ( \version_compare( PHPUnit_Version::id(), '7.0.0', '<' ) ) {
// PHPUnit 6.4.4 < 7.0.0.
require_once __DIR__ . '/src/TestListeners/TestListenerDefaultImplementationPHPUnit6.php';
return;
}

// PHPUnit >= 7.0.0.
require_once __DIR__ . '/src/TestListeners/TestListenerDefaultImplementationPHPUnitGte7.php';
}

Expand Down
150 changes: 0 additions & 150 deletions src/TestListeners/TestListenerDefaultImplementationPHPUnit6.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/TestListeners/Fixtures/Failure.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Failure extends TestCase {
*
* @return void
*/
protected function runTest() {
protected function testForListener() {
$this->fail();
}
}
24 changes: 0 additions & 24 deletions tests/TestListeners/Fixtures/FailurePHPUnitGte7.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/TestListeners/Fixtures/Incomplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Incomplete extends TestCase {
*
* @return void
*/
protected function runTest() {
protected function testForListener() {
$this->markTestIncomplete( 'Test incomplete' );
}
}
24 changes: 0 additions & 24 deletions tests/TestListeners/Fixtures/IncompletePHPUnitGte7.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/TestListeners/Fixtures/Risky.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Risky extends TestCase {
*
* @return void
*/
protected function runTest() {
protected function testForListener() {
$this->markAsRisky();
}
}
24 changes: 0 additions & 24 deletions tests/TestListeners/Fixtures/RiskyPHPUnitGte7.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/TestListeners/Fixtures/Skipped.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Skipped extends TestCase {
*
* @return void
*/
protected function runTest() {
protected function testForListener() {
$this->markTestSkipped( 'Skipped test' );
}
}
24 changes: 0 additions & 24 deletions tests/TestListeners/Fixtures/SkippedPHPUnitGte7.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/TestListeners/Fixtures/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Success extends TestCase {
*
* @return void
*/
protected function runTest() {
protected function testForListener() {
$this->assertTrue( true );
}
}
24 changes: 0 additions & 24 deletions tests/TestListeners/Fixtures/SuccessPHPUnitGte7.php

This file was deleted.

Loading

0 comments on commit 1dcba37

Please sign in to comment.