mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 10:44:26 +00:00
Build/Test Tools: Add support for PHPUnit 6+.
This adds a compatibility shim for the new namespaced structure of PHPUnit and the removed `setExpectedException()` method. In addition, this updates the Travis config so PHPUnit 6.1 is used where appropriate. Props miyauchi, gitlost. Fixes #39822 git-svn-id: https://develop.svn.wordpress.org/trunk@40536 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -415,6 +415,27 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
array_push( $this->expected_doing_it_wrong, $doing_it_wrong );
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPUnit 6+ compatibility shim.
|
||||
*
|
||||
* @param mixed $exception
|
||||
* @param string $message
|
||||
* @param int|string $code
|
||||
*/
|
||||
public function setExpectedException( $exception, $message = '', $code = null ) {
|
||||
if ( is_callable( 'parent::setExpectedException' ) ) {
|
||||
parent::setExpectedException( $exception, $message, $code );
|
||||
} else {
|
||||
$this->expectException( $exception );
|
||||
if ( '' !== $message ) {
|
||||
$this->expectExceptionMessage( $message );
|
||||
}
|
||||
if ( null !== $code ) {
|
||||
$this->expectExceptionCode( $code );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deprecated_function_run( $function ) {
|
||||
if ( ! in_array( $function, $this->caught_deprecated ) )
|
||||
$this->caught_deprecated[] = $function;
|
||||
|
||||
Reference in New Issue
Block a user