mirror of
git://develop.git.wordpress.org/
synced 2025-01-17 12:58:25 +01:00
Tests: Avoid an infinite loop in Spy_REST_Server
if a non-existing method is called.
Follow-up to [34928]. Props xknown, joemcgill. Fixes #59601. git-svn-id: https://develop.svn.wordpress.org/trunk@57133 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9099d9789b
commit
09a2050fca
@ -25,6 +25,10 @@ class Spy_REST_Server extends WP_REST_Server {
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call( $method, $args ) {
|
||||
if ( ! method_exists( $this, $method ) ) {
|
||||
throw new Error( sprintf( 'Call to undefined method %s::%s()', get_class( $this ), $method ) );
|
||||
}
|
||||
|
||||
return call_user_func_array( array( $this, $method ), $args );
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,11 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
return 'Spy_REST_Server';
|
||||
}
|
||||
|
||||
public function test_rest_get_server_fails_with_undefined_method() {
|
||||
$this->expectException( Error::class );
|
||||
rest_get_server()->does_not_exist();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the main classes are loaded.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user