Changeset 64006
- Timestamp:
- 09/29/2026 09:49:08 PM (5 weeks ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/rest-api.php (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api.php
r63882 r64006 18 18 parent::set_up(); 19 19 20 // Override the normal server with our spying server. 21 $GLOBALS['wp_rest_server'] = new Spy_REST_Server(); 22 do_action( 'rest_api_init', $GLOBALS['wp_rest_server'] ); 20 $GLOBALS['wp_rest_server'] = null; 23 21 } 24 22 25 23 public function tear_down() { 24 $GLOBALS['wp_rest_server'] = null; 26 25 remove_filter( 'wp_rest_server_class', array( $this, 'filter_wp_rest_server_class' ) ); 27 26 parent::tear_down(); … … 90 89 */ 91 90 public function test_route_canonicalized() { 91 rest_get_server(); 92 92 93 register_rest_route( 93 94 'test-ns', … … 126 127 */ 127 128 public function test_route_canonicalized_multiple() { 129 rest_get_server(); 130 128 131 register_rest_route( 129 132 'test-ns', … … 169 172 */ 170 173 public function test_route_merge() { 174 rest_get_server(); 175 171 176 register_rest_route( 172 177 'test-ns', … … 198 203 */ 199 204 public function test_route_override() { 205 rest_get_server(); 206 200 207 register_rest_route( 201 208 'test-ns', … … 236 243 */ 237 244 public function test_route_reject_empty_namespace() { 245 rest_get_server(); 246 238 247 register_rest_route( 239 248 '', … … 256 265 */ 257 266 public function test_route_reject_empty_route() { 267 rest_get_server(); 268 258 269 register_rest_route( 259 270 '/test-empty-route', … … 279 290 280 291 public function test_route_method() { 292 rest_get_server(); 293 281 294 register_rest_route( 282 295 'test-ns', … … 298 311 */ 299 312 public function test_route_method_string() { 313 rest_get_server(); 314 300 315 register_rest_route( 301 316 'test-ns', … … 317 332 */ 318 333 public function test_route_method_array() { 334 rest_get_server(); 335 319 336 register_rest_route( 320 337 'test-ns', … … 342 359 */ 343 360 public function test_route_method_comma_separated() { 361 rest_get_server(); 362 344 363 register_rest_route( 345 364 'test-ns', … … 372 391 */ 373 392 public function test_route_method_array_with_comma_separated_values() { 393 rest_get_server(); 394 374 395 global $wp_rest_server; 375 396 … … 407 428 */ 408 429 public function test_route_method_array_with_multi_method_constant() { 430 rest_get_server(); 431 409 432 global $wp_rest_server; 410 433 … … 441 464 */ 442 465 public function test_route_method_array_with_multi_method_constant_dispatches() { 466 rest_get_server(); 467 443 468 register_rest_route( 444 469 'test-ns', … … 468 493 */ 469 494 public function test_route_method_empty_array() { 495 rest_get_server(); 496 470 497 global $wp_rest_server; 471 498 … … 486 513 487 514 public function test_options_request() { 515 rest_get_server(); 516 488 517 register_rest_route( 489 518 'test-ns', … … 509 538 */ 510 539 public function test_options_request_not_options() { 540 rest_get_server(); 541 511 542 register_rest_route( 512 543 'test-ns', … … 1044 1075 1045 1076 public function test_register_rest_route_without_server() { 1077 rest_get_server(); 1078 1046 1079 $GLOBALS['wp_rest_server'] = null; 1047 1080 add_filter( 'wp_rest_server_class', array( $this, 'filter_wp_rest_server_class' ) ); … … 1062 1095 1063 1096 public function test_rest_preload_api_request_with_method() { 1064 $rest_server = $GLOBALS['wp_rest_server'];1065 $GLOBALS['wp_rest_server'] = null;1066 1067 1097 $preload_paths = array( 1068 1098 '/wp/v2/types', … … 1078 1108 $this->assertSame( array_keys( $preload_data ), array( '/wp/v2/types', 'OPTIONS' ) ); 1079 1109 $this->assertArrayHasKey( '/wp/v2/media', $preload_data['OPTIONS'] ); 1080 1081 $GLOBALS['wp_rest_server'] = $rest_server;1082 1110 } 1083 1111 … … 1092 1120 */ 1093 1121 public function test_rest_preload_api_request_removes_trailing_slashes( $preload_path, $expected_preload_path ) { 1094 $rest_server = $GLOBALS['wp_rest_server'];1095 $GLOBALS['wp_rest_server'] = null;1096 1097 1122 $actual_preload_path = rest_preload_api_request( array(), $preload_path ); 1098 1123 if ( '' !== $preload_path ) { … … 1100 1125 } 1101 1126 $this->assertSame( $expected_preload_path, $actual_preload_path ); 1102 1103 $GLOBALS['wp_rest_server'] = $rest_server;1104 1127 } 1105 1128 … … 1173 1196 */ 1174 1197 public function test_register_route_with_invalid_namespace() { 1198 rest_get_server(); 1199 1175 1200 $this->setExpectedIncorrectUsage( 'register_rest_route' ); 1176 1201 … … 1194 1219 */ 1195 1220 public function test_register_route_with_missing_permission_callback_top_level_route() { 1221 rest_get_server(); 1222 1196 1223 $this->setExpectedIncorrectUsage( 'register_rest_route' ); 1197 1224 … … 1211 1238 */ 1212 1239 public function test_register_route_with_missing_permission_callback_single_wrapped_route() { 1240 rest_get_server(); 1241 1213 1242 $this->setExpectedIncorrectUsage( 'register_rest_route' ); 1214 1243 … … 1231 1260 */ 1232 1261 public function test_register_route_with_missing_permission_callback_multiple_wrapped_route() { 1262 rest_get_server(); 1263 1233 1264 $this->setExpectedIncorrectUsage( 'register_rest_route' ); 1234 1265 … … 2869 2900 */ 2870 2901 public function test_route_args_is_array_of_arrays() { 2902 rest_get_server(); 2903 2871 2904 $this->setExpectedIncorrectUsage( 'register_rest_route' ); 2872 2905
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)