Skip to content

Commit 73bf346

Browse files
authored
Merge pull request #108 from Yoast/2.0/phpunit-10/remove-expectphpexception-polyfill
PHPUnit 10 | Remove support for expecting PHP notices/exceptions
2 parents 7de7855 + e349fe3 commit 73bf346

File tree

9 files changed

+0
-322
lines changed

9 files changed

+0
-322
lines changed

README.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -233,32 +233,6 @@ These methods were introduced in PHPUnit 7.5.0 as alternatives to using `Assert:
233233
[`Assert::assertEqualsWithDelta()`]: https://docs.phpunit.de/en/9.6/assertions.html#assertequalswithdelta
234234
[`Assert::assertNotEqualsWithDelta()`]: https://docs.phpunit.de/en/9.6/assertions.html#assertequalswithdelta
235235

236-
#### PHPUnit < 8.4.0: `Yoast\PHPUnitPolyfills\Polyfills\ExpectPHPException`
237-
238-
Polyfills the following methods:
239-
| | | |
240-
|-------------------------------------|--------------------------------|---------------------------------------|
241-
| `TestCase::`[`expectError()`] | [`expectErrorMessage()`] | [`expectErrorMessageMatches()`] |
242-
| `TestCase::`[`expectWarning()`] | [`expectWarningMessage()`] | [`expectWarningMessageMatches()`] |
243-
| `TestCase::`[`expectNotice()`] | [`expectNoticeMessage()`] | [`expectNoticeMessageMatches()`] |
244-
| `TestCase::`[`expectDeprecation()`] | [`expectDeprecationMessage()`] | [`expectDeprecationMessageMatches()`] |
245-
246-
These methods were introduced in PHPUnit 8.4.0 as alternatives to using `TestCase::expectException()` et al for expecting PHP native errors, warnings and notices.
247-
Using `TestCase::expectException*()` for testing PHP native notices was soft deprecated in PHPUnit 8.4.0, hard deprecated (warning) in PHPUnit 9.0.0 and (will be) removed in PHPUnit 10.0.0.
248-
249-
[`expectError()`]: https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#testing-php-errors-warnings-and-notices
250-
[`expectErrorMessage()`]: https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#testing-php-errors-warnings-and-notices
251-
[`expectErrorMessageMatches()`]: https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#testing-php-errors-warnings-and-notices
252-
[`expectWarning()`]: https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#testing-php-errors-warnings-and-notices
253-
[`expectWarningMessage()`]: https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#testing-php-errors-warnings-and-notices
254-
[`expectWarningMessageMatches()`]: https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#testing-php-errors-warnings-and-notices
255-
[`expectNotice()`]: https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#testing-php-errors-warnings-and-notices
256-
[`expectNoticeMessage()`]: https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#testing-php-errors-warnings-and-notices
257-
[`expectNoticeMessageMatches()`]: https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#testing-php-errors-warnings-and-notices
258-
[`expectDeprecation()`]: https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#testing-php-errors-warnings-and-notices
259-
[`expectDeprecationMessage()`]: https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#testing-php-errors-warnings-and-notices
260-
[`expectDeprecationMessageMatches()`]: https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#testing-php-errors-warnings-and-notices
261-
262236
#### PHPUnit < 8.4.0: `Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionMessageMatches`
263237

264238
Polyfills the [`TestCase::expectExceptionMessageMatches()`] method.

phpunitpolyfills-autoload.php

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ public static function load( $className ) {
6767
self::loadAssertEqualsSpecializations();
6868
return true;
6969

70-
case 'Yoast\PHPUnitPolyfills\Polyfills\ExpectPHPException':
71-
self::loadExpectPHPException();
72-
return true;
73-
7470
case 'Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionMessageMatches':
7571
self::loadExpectExceptionMessageMatches();
7672
return true;
@@ -191,57 +187,6 @@ public static function loadAssertEqualsSpecializations() {
191187
require_once __DIR__ . '/src/Polyfills/AssertEqualsSpecializations_Empty.php';
192188
}
193189

194-
/**
195-
* Load the ExpectPHPException polyfill or an empty trait with the same name
196-
* if a PHPUnit version is used which already contains this functionality.
197-
*
198-
* Includes aliasing any PHPUnit native classes needed for this functionality
199-
* which aren't available under their namespaced name in PHPUnit 5.x.
200-
*
201-
* @return void
202-
*/
203-
public static function loadExpectPHPException() {
204-
/*
205-
* Alias the PHPUnit 5.x Error classes to their PHPUnit >= 6 name.
206-
*
207-
* {@internal The `class_exists` wrappers are needed to play nice with
208-
* PHPUnit bootstrap files of test suites implementing this library
209-
* which may be creating cross-version compatibility in a similar manner.}}
210-
*/
211-
if ( \class_exists( 'PHPUnit_Framework_Error' ) === true
212-
&& \class_exists( 'PHPUnit\Framework\Error\Error' ) === false
213-
) {
214-
\class_alias( 'PHPUnit_Framework_Error', 'PHPUnit\Framework\Error\Error' );
215-
}
216-
217-
if ( \class_exists( 'PHPUnit_Framework_Error_Warning' ) === true
218-
&& \class_exists( 'PHPUnit\Framework\Error\Warning' ) === false
219-
) {
220-
\class_alias( 'PHPUnit_Framework_Error_Warning', 'PHPUnit\Framework\Error\Warning' );
221-
}
222-
223-
if ( \class_exists( 'PHPUnit_Framework_Error_Notice' ) === true
224-
&& \class_exists( 'PHPUnit\Framework\Error\Notice' ) === false
225-
) {
226-
\class_alias( 'PHPUnit_Framework_Error_Notice', 'PHPUnit\Framework\Error\Notice' );
227-
}
228-
229-
if ( \class_exists( 'PHPUnit_Framework_Error_Deprecated' ) === true
230-
&& \class_exists( 'PHPUnit\Framework\Error\Deprecated' ) === false
231-
) {
232-
\class_alias( 'PHPUnit_Framework_Error_Deprecated', 'PHPUnit\Framework\Error\Deprecated' );
233-
}
234-
235-
if ( \method_exists( TestCase::class, 'expectErrorMessage' ) === false ) {
236-
// PHPUnit < 8.4.0.
237-
require_once __DIR__ . '/src/Polyfills/ExpectPHPException.php';
238-
return;
239-
}
240-
241-
// PHPUnit >= 8.4.0.
242-
require_once __DIR__ . '/src/Polyfills/ExpectPHPException_Empty.php';
243-
}
244-
245190
/**
246191
* Load the ExpectExceptionMessageMatches polyfill or an empty trait with the same name
247192
* if a PHPUnit version is used which already contains this functionality.

src/Polyfills/ExpectPHPException.php

Lines changed: 0 additions & 148 deletions
This file was deleted.

src/Polyfills/ExpectPHPException_Empty.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/TestCases/TestCasePHPUnitGte8.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Yoast\PHPUnitPolyfills\Polyfills\AssertObjectEquals;
1111
use Yoast\PHPUnitPolyfills\Polyfills\EqualToSpecializations;
1212
use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionMessageMatches;
13-
use Yoast\PHPUnitPolyfills\Polyfills\ExpectPHPException;
1413

1514
/**
1615
* Basic test case for use with PHPUnit >= 8.
@@ -30,7 +29,6 @@ abstract class TestCase extends PHPUnit_TestCase {
3029
use AssertObjectEquals;
3130
use EqualToSpecializations;
3231
use ExpectExceptionMessageMatches;
33-
use ExpectPHPException;
3432

3533
/**
3634
* This method is called before the first test of this test class is run.

src/TestCases/TestCasePHPUnitLte7.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Yoast\PHPUnitPolyfills\Polyfills\EqualToSpecializations;
1515
use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionMessageMatches;
1616
use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionObject;
17-
use Yoast\PHPUnitPolyfills\Polyfills\ExpectPHPException;
1817

1918
/**
2019
* Basic test case for use with PHPUnit <= 7.
@@ -38,7 +37,6 @@ abstract class TestCase extends PHPUnit_TestCase {
3837
use EqualToSpecializations;
3938
use ExpectExceptionMessageMatches;
4039
use ExpectExceptionObject;
41-
use ExpectPHPException;
4240

4341
/**
4442
* This method is called before the first test of this test class is run.

src/TestCases/XTestCase.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Yoast\PHPUnitPolyfills\Polyfills\EqualToSpecializations;
1515
use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionMessageMatches;
1616
use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionObject;
17-
use Yoast\PHPUnitPolyfills\Polyfills\ExpectPHPException;
1817

1918
/**
2019
* Basic test case for use with PHPUnit cross-version.
@@ -40,7 +39,6 @@ abstract class XTestCase extends PHPUnit_TestCase {
4039
use EqualToSpecializations;
4140
use ExpectExceptionMessageMatches;
4241
use ExpectExceptionObject;
43-
use ExpectPHPException;
4442

4543
/**
4644
* This method is called before the first test of this test class is run.

tests/Polyfills/ExpectPHPExceptionTest.php

Lines changed: 0 additions & 68 deletions
This file was deleted.

tests/TestCases/TestCaseTestTrait.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,6 @@ final public function testAvailabilityAssertEqualsSpecializationsTrait() {
6565
static::assertEqualsIgnoringCase( 'a', 'A' );
6666
}
6767

68-
/**
69-
* Test availability of trait polyfilled PHPUnit methods [5].
70-
*
71-
* @return void
72-
*/
73-
final public function testAvailabilityExpectPHPExceptionTrait() {
74-
$this->expectDeprecation();
75-
76-
\trigger_error( 'foo', \E_USER_DEPRECATED );
77-
}
78-
7968
/**
8069
* Test availability of trait polyfilled PHPUnit methods [6].
8170
*

0 commit comments

Comments
 (0)