mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Build/Test Tools: Simplify redundant PHPUnit shim for setExpectedException().
PHPUnit 6 deprecated the `setExpectedException()` method in favor of the `expectException()`, `expectExceptionMessage()`, and `expectExceptionCode()` methods. `WP_UnitTestCase_Base::setExpectedException()` backfilled the old method. As the PHPUnit Polyfills have a polyfill for the ''new'' method, this backfill can now be simplified. This backfill ''should'' be removed in a future iteration, but is, for now, left in place so as not to break backward compatibility for plugin/theme test suites which extend the WP native test suite for their integration tests. Follow-up to [48996], [48997], [51559-51561]. Props jrf. See #46149. git-svn-id: https://develop.svn.wordpress.org/trunk@51562 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -564,23 +564,25 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPUnit 6+ compatibility shim.
|
||||
* Redundant PHPUnit 6+ compatibility shim. DO NOT USE!
|
||||
*
|
||||
* This method is only left in place for backward compatibility reasons.
|
||||
*
|
||||
* @deprecated 5.9.0 Use the PHPUnit native expectException*() methods directly.
|
||||
*
|
||||
* @param mixed $exception
|
||||
* @param string $message
|
||||
* @param int|string $code
|
||||
*/
|
||||
public function setExpectedException( $exception, $message = '', $code = null ) {
|
||||
if ( method_exists( 'PHPUnit_Framework_TestCase', 'setExpectedException' ) ) {
|
||||
parent::setExpectedException( $exception, $message, $code );
|
||||
} else {
|
||||
$this->expectException( $exception );
|
||||
if ( '' !== $message ) {
|
||||
$this->expectExceptionMessage( $message );
|
||||
}
|
||||
if ( null !== $code ) {
|
||||
$this->expectExceptionCode( $code );
|
||||
}
|
||||
$this->expectException( $exception );
|
||||
|
||||
if ( '' !== $message ) {
|
||||
$this->expectExceptionMessage( $message );
|
||||
}
|
||||
|
||||
if ( null !== $code ) {
|
||||
$this->expectExceptionCode( $code );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user