diff --git a/README.md b/README.md index d7e6a0f..5a296c4 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/phpunitpolyfills-autoload.php b/phpunitpolyfills-autoload.php index 363ef49..273a5d1 100644 --- a/phpunitpolyfills-autoload.php +++ b/phpunitpolyfills-autoload.php @@ -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; @@ -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. diff --git a/src/Polyfills/ExpectExceptionObject.php b/src/Polyfills/ExpectExceptionObject.php deleted file mode 100644 index 682cfe6..0000000 --- a/src/Polyfills/ExpectExceptionObject.php +++ /dev/null @@ -1,28 +0,0 @@ -expectException( \get_class( $exception ) ); - $this->expectExceptionMessage( $exception->getMessage() ); - $this->expectExceptionCode( $exception->getCode() ); - } -} diff --git a/src/Polyfills/ExpectExceptionObject_Empty.php b/src/Polyfills/ExpectExceptionObject_Empty.php deleted file mode 100644 index 499bee2..0000000 --- a/src/Polyfills/ExpectExceptionObject_Empty.php +++ /dev/null @@ -1,8 +0,0 @@ -= 6.4.0 in which this polyfill is not needed. - */ -trait ExpectExceptionObject {} diff --git a/src/TestCases/TestCasePHPUnitLte7.php b/src/TestCases/TestCasePHPUnitLte7.php index 9fb9801..b1a6464 100644 --- a/src/TestCases/TestCasePHPUnitLte7.php +++ b/src/TestCases/TestCasePHPUnitLte7.php @@ -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. @@ -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. diff --git a/src/TestCases/XTestCase.php b/src/TestCases/XTestCase.php index 328f4f9..acde81b 100644 --- a/src/TestCases/XTestCase.php +++ b/src/TestCases/XTestCase.php @@ -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. @@ -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. diff --git a/tests/Polyfills/ExpectExceptionObjectTest.php b/tests/Polyfills/ExpectExceptionObjectTest.php deleted file mode 100644 index 3d23c52..0000000 --- a/tests/Polyfills/ExpectExceptionObjectTest.php +++ /dev/null @@ -1,33 +0,0 @@ -expectExceptionObject( $exception ); - - throw new Exception( 'message', 101 ); - } -} diff --git a/tests/TestCases/TestCaseTestTrait.php b/tests/TestCases/TestCaseTestTrait.php index ae9a67b..9bdacf6 100644 --- a/tests/TestCases/TestCaseTestTrait.php +++ b/tests/TestCases/TestCaseTestTrait.php @@ -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]. *