diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index cff6b536f1..62287650cf 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -249,6 +249,7 @@
+
diff --git a/tests/phpunit/includes/mock-invokable.php b/tests/phpunit/includes/mock-invokable.php
new file mode 100644
index 0000000000..03db3e053a
--- /dev/null
+++ b/tests/phpunit/includes/mock-invokable.php
@@ -0,0 +1,17 @@
+request = new WP_REST_Request();
}
+ /**
+ * Called before setting up all tests.
+ */
+ public static function set_up_before_class() {
+ parent::set_up_before_class();
+
+ // Require files that need to load once.
+ require_once DIR_TESTROOT . '/includes/mock-invokable.php';
+ }
+
public function test_header() {
$value = 'application/x-wp-example';
@@ -1014,7 +1024,7 @@ class Tests_REST_Request extends WP_UnitTestCase {
$request->set_query_params( array( 'test' => 'value' ) );
$error = new WP_Error( 'error_code', __( 'Error Message' ), array( 'status' => 400 ) );
- $callback = $this->createPartialMock( 'stdClass', array( '__invoke' ) );
+ $callback = $this->createPartialMock( 'Mock_Invokable', array( '__invoke' ) );
$callback->expects( self::once() )->method( '__invoke' )->with( self::identicalTo( $request ) )->willReturn( $error );
$request->set_attributes(
array(
@@ -1038,7 +1048,7 @@ class Tests_REST_Request extends WP_UnitTestCase {
$request->set_query_params( array( 'test' => 'value' ) );
$error = new WP_Error( 'error_code', __( 'Error Message' ), array( 'status' => 400 ) );
- $callback = $this->createPartialMock( 'stdClass', array( '__invoke' ) );
+ $callback = $this->createPartialMock( 'Mock_Invokable', array( '__invoke' ) );
$callback->expects( self::once() )->method( '__invoke' )->with( self::identicalTo( $request ) )->willReturn( $error );
$request->set_attributes(
array(
@@ -1056,7 +1066,7 @@ class Tests_REST_Request extends WP_UnitTestCase {
$request = new WP_REST_Request();
$request->set_query_params( array( 'test' => 'value' ) );
- $callback = $this->createPartialMock( 'stdClass', array( '__invoke' ) );
+ $callback = $this->createPartialMock( 'Mock_Invokable', array( '__invoke' ) );
$callback->expects( self::never() )->method( '__invoke' );
$request->set_attributes(
array(
diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php
index 248886a76e..33e1f70506 100644
--- a/tests/phpunit/tests/rest-api/rest-server.php
+++ b/tests/phpunit/tests/rest-api/rest-server.php
@@ -35,6 +35,16 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
parent::tear_down();
}
+ /**
+ * Called before setting up all tests.
+ */
+ public static function set_up_before_class() {
+ parent::set_up_before_class();
+
+ // Require files that need to load once.
+ require_once DIR_TESTROOT . '/includes/mock-invokable.php';
+ }
+
public function test_envelope() {
$data = array(
'amount of arbitrary data' => 'alot',
@@ -1630,9 +1640,9 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
* @ticket 50244
*/
public function test_callbacks_are_not_executed_if_request_validation_fails() {
- $callback = $this->createPartialMock( 'stdClass', array( '__invoke' ) );
+ $callback = $this->createPartialMock( 'Mock_Invokable', array( '__invoke' ) );
$callback->expects( self::never() )->method( '__invoke' );
- $permission_callback = $this->createPartialMock( 'stdClass', array( '__invoke' ) );
+ $permission_callback = $this->createPartialMock( 'Mock_Invokable', array( '__invoke' ) );
$permission_callback->expects( self::never() )->method( '__invoke' );
register_rest_route(