Changeset 41238 for trunk/tests/phpunit/tests/rest-api.php
- Timestamp:
- 08/10/2017 01:37:30 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api.php
r41139 r41238 17 17 // Override the normal server with our spying server. 18 18 $GLOBALS['wp_rest_server'] = new Spy_REST_Server(); 19 parent::setup(); 19 parent::setUp(); 20 } 21 22 public function tearDown() { 23 remove_filter( 'wp_rest_server_class', array( $this, 'filter_wp_rest_server_class' ) ); 24 parent::tearDown(); 20 25 } 21 26 … … 447 452 $this->assertEquals( $value, rest_parse_date( $string, true ) ); 448 453 } 454 455 public function filter_wp_rest_server_class( $class_name ) { 456 return 'Spy_REST_Server'; 457 } 458 459 public function test_register_rest_route_without_server() { 460 $GLOBALS['wp_rest_server'] = null; 461 add_filter( 'wp_rest_server_class', array( $this, 'filter_wp_rest_server_class' ) ); 462 463 register_rest_route( 'test-ns', '/test', array( 464 'methods' => array( 'GET' ), 465 'callback' => '__return_null', 466 ) ); 467 468 $routes = $GLOBALS['wp_rest_server']->get_routes(); 469 $this->assertEquals( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true ) ); 470 } 449 471 }
Note: See TracChangeset
for help on using the changeset viewer.