From f5bf5ba8b8f6bfe0015527261800e9e3264326f0 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sun, 23 Apr 2017 11:45:46 +0000 Subject: [PATCH] Build/Test Tools: Move the `setExpectedException()` method into the `WP_Ajax_UnitTestCase` class to avoid a fatal error when PHPUnit 3.6 is in use. This needs more investigation but it gets the test suite on PHP 5.2 passing again. See #39822 git-svn-id: https://develop.svn.wordpress.org/trunk@40539 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/testcase-ajax.php | 21 +++++++++++++++++++++ tests/phpunit/includes/testcase.php | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/phpunit/includes/testcase-ajax.php b/tests/phpunit/includes/testcase-ajax.php index 787e6bf5fd..19a87b2a74 100644 --- a/tests/phpunit/includes/testcase-ajax.php +++ b/tests/phpunit/includes/testcase-ajax.php @@ -200,4 +200,25 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase { if ( !empty( $buffer ) ) $this->_last_response = $buffer; } + + /** + * 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 ); + } + } + } } diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index b559cf6f19..554de7e578 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -415,27 +415,6 @@ 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;