mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
REST API: Require namespace when registering routes.
Props danielbachhuber. Fixes #34416. git-svn-id: https://develop.svn.wordpress.org/trunk@35651 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -148,6 +148,34 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
$this->assertTrue( $endpoint[0]['should_exist'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that we reject routes without namespaces
|
||||
*
|
||||
* @expectedIncorrectUsage register_rest_route
|
||||
*/
|
||||
public function test_route_reject_empty_namespace() {
|
||||
register_rest_route( '', '/test-empty-namespace', array(
|
||||
'methods' => array( 'POST' ),
|
||||
'callback' => '__return_null',
|
||||
), true );
|
||||
$endpoints = $GLOBALS['wp_rest_server']->get_routes();
|
||||
$this->assertFalse( isset( $endpoints['/test-empty-namespace'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that we reject empty routes
|
||||
*
|
||||
* @expectedIncorrectUsage register_rest_route
|
||||
*/
|
||||
public function test_route_reject_empty_route() {
|
||||
register_rest_route( '/test-empty-route', '', array(
|
||||
'methods' => array( 'POST' ),
|
||||
'callback' => '__return_null',
|
||||
), true );
|
||||
$endpoints = $GLOBALS['wp_rest_server']->get_routes();
|
||||
$this->assertFalse( isset( $endpoints['/test-empty-route'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* The rest_route query variable should be registered.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user