Skip to content

Commit

Permalink
Drop support for PHPUnit < 6.4 [1]
Browse files Browse the repository at this point in the history
Remove the `ExpectExceptionObject` polyfill and all references to it.
  • Loading branch information
jrfnl committed Jul 17, 2024
1 parent ade6770 commit eb6a39c
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 116 deletions.
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,6 @@ Features

### Polyfill traits

#### PHPUnit < 6.4.0: `Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionObject`

Polyfills the [`TestCase::expectExceptionObject()`] method to test all aspects of an `Exception` by passing an object to the method.

This method was introduced in PHPUnit 6.4.0.

[`TestCase::expectExceptionObject()`]: https://docs.phpunit.de/en/10.5/writing-tests-for-phpunit.html#testing-exceptions

#### PHPUnit < 7.5.0: `Yoast\PHPUnitPolyfills\Polyfills\AssertIsType`

Polyfills the following methods:
Expand Down
21 changes: 0 additions & 21 deletions phpunitpolyfills-autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public static function load( $className ) {
}

switch ( $className ) {
case 'Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionObject':
self::loadExpectExceptionObject();
return true;

case 'Yoast\PHPUnitPolyfills\Polyfills\AssertIsType':
self::loadAssertIsType();
return true;
Expand Down Expand Up @@ -115,23 +111,6 @@ public static function load( $className ) {
return false;
}

/**
* Load the ExpectExceptionObject polyfill or an empty trait with the same name
* if a PHPUnit version is used which already contains this functionality.
*
* @return void
*/
public static function loadExpectExceptionObject() {
if ( \method_exists( TestCase::class, 'expectExceptionObject' ) === false ) {
// PHPUnit < 6.4.0.
require_once __DIR__ . '/src/Polyfills/ExpectExceptionObject.php';
return;
}

// PHPUnit >= 6.4.0.
require_once __DIR__ . '/src/Polyfills/ExpectExceptionObject_Empty.php';
}

/**
* Load the AssertIsType polyfill or an empty trait with the same name
* if a PHPUnit version is used which already contains this functionality.
Expand Down
28 changes: 0 additions & 28 deletions src/Polyfills/ExpectExceptionObject.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/Polyfills/ExpectExceptionObject_Empty.php

This file was deleted.

2 changes: 0 additions & 2 deletions src/TestCases/TestCasePHPUnitLte7.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Yoast\PHPUnitPolyfills\Polyfills\AssertStringContains;
use Yoast\PHPUnitPolyfills\Polyfills\EqualToSpecializations;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionMessageMatches;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionObject;

/**
* Basic test case for use with PHPUnit <= 7.
Expand All @@ -42,7 +41,6 @@ abstract class TestCase extends PHPUnit_TestCase {
use AssertStringContains;
use EqualToSpecializations;
use ExpectExceptionMessageMatches;
use ExpectExceptionObject;

/**
* This method is called before the first test of this test class is run.
Expand Down
2 changes: 0 additions & 2 deletions src/TestCases/XTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Yoast\PHPUnitPolyfills\Polyfills\AssertStringContains;
use Yoast\PHPUnitPolyfills\Polyfills\EqualToSpecializations;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionMessageMatches;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionObject;

/**
* Basic test case for use with PHPUnit cross-version.
Expand Down Expand Up @@ -48,7 +47,6 @@ abstract class XTestCase extends PHPUnit_TestCase {
use AssertStringContains;
use EqualToSpecializations;
use ExpectExceptionMessageMatches;
use ExpectExceptionObject;

/**
* This method is called before the first test of this test class is run.
Expand Down
33 changes: 0 additions & 33 deletions tests/Polyfills/ExpectExceptionObjectTest.php

This file was deleted.

14 changes: 0 additions & 14 deletions tests/TestCases/TestCaseTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ final public static function dataHaveFixtureMethodsBeenTriggered() {
];
}

/**
* Test availability of trait polyfilled PHPUnit methods [1].
*
* @return void
*
* @throws Exception For testing purposes.
*/
final public function testAvailabilityExpectExceptionObjectTrait() {
$exception = new Exception( 'message', 101 );
$this->expectExceptionObject( $exception );

throw new Exception( 'message', 101 );
}

/**
* Test availability of trait polyfilled PHPUnit methods [2].
*
Expand Down

0 comments on commit eb6a39c

Please sign in to comment.