Make WordPress Core

Ticket #59601: 59601.diff

File 59601.diff, 1.0 KB (added by xknown, 3 years ago)
  • tests/phpunit/includes/spy-rest-server.php

    diff --git a/tests/phpunit/includes/spy-rest-server.php b/tests/phpunit/includes/spy-rest-server.php
    index 49cda8748a..8bf1af43bd 100644
    a b class Spy_REST_Server extends WP_REST_Server {  
    2525         * @return mixed
    2626         */
    2727        public function __call( $method, $args ) {
     28                if ( ! method_exists( $this, $method ) ) {
     29                        throw new \Error( sprintf( 'Call to undefined method %s::%s', get_class( $this ), $method ) );
     30                }
    2831                return call_user_func_array( array( $this, $method ), $args );
    2932        }
    3033
  • tests/phpunit/tests/rest-api.php

    diff --git a/tests/phpunit/tests/rest-api.php b/tests/phpunit/tests/rest-api.php
    index 4a575b8803..2c9156cb30 100644
    a b class Tests_REST_API extends WP_UnitTestCase {  
    25372537
    25382538                $this->assertTrue( $registered );
    25392539        }
     2540
     2541        public function test_rest_get_server_fails_with_undefined_method() {
     2542                $this->expectException( \Error::class );
     2543                rest_get_server()->does_not_exist();
     2544        }
    25402545}