- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php
r42228 r42343 15 15 16 16 public static function wpSetUpBeforeClass( $factory ) { 17 self::$editor_id = $factory->user->create( array( 18 'role' => 'editor', 19 ) ); 17 self::$editor_id = $factory->user->create( 18 array( 19 'role' => 'editor', 20 ) 21 ); 20 22 } 21 23 … … 30 32 // reregister the route as we now have a template available. 31 33 $GLOBALS['wp_rest_server']->override_by_default = true; 32 $controller = new WP_REST_Posts_Controller( 'page' );34 $controller = new WP_REST_Posts_Controller( 'page' ); 33 35 $controller->register_routes(); 34 36 $GLOBALS['wp_rest_server']->override_by_default = false; … … 45 47 public function test_context_param() { 46 48 // Collection 47 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages' );48 $response = $this->server->dispatch( $request ); 49 $data = $response->get_data();49 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages' ); 50 $response = $this->server->dispatch( $request ); 51 $data = $response->get_data(); 50 52 $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); 51 53 $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 52 54 // Single 53 $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) );54 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages/' . $page_id );55 $response = $this->server->dispatch( $request ); 56 $data = $response->get_data();55 $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); 56 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages/' . $page_id ); 57 $response = $this->server->dispatch( $request ); 58 $data = $response->get_data(); 57 59 $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); 58 60 $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); … … 60 62 61 63 public function test_registered_query_params() { 62 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages' );63 $response = $this->server->dispatch( $request ); 64 $data = $response->get_data();65 $keys = array_keys( $data['endpoints'][0]['args'] );64 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages' ); 65 $response = $this->server->dispatch( $request ); 66 $data = $response->get_data(); 67 $keys = array_keys( $data['endpoints'][0]['args'] ); 66 68 sort( $keys ); 67 $this->assertEquals( array( 68 'after', 69 'author', 70 'author_exclude', 71 'before', 72 'context', 73 'exclude', 74 'include', 75 'menu_order', 76 'offset', 77 'order', 78 'orderby', 79 'page', 80 'parent', 81 'parent_exclude', 82 'per_page', 83 'search', 84 'slug', 85 'status', 86 ), $keys ); 69 $this->assertEquals( 70 array( 71 'after', 72 'author', 73 'author_exclude', 74 'before', 75 'context', 76 'exclude', 77 'include', 78 'menu_order', 79 'offset', 80 'order', 81 'orderby', 82 'page', 83 'parent', 84 'parent_exclude', 85 'per_page', 86 'search', 87 'slug', 88 'status', 89 ), $keys 90 ); 87 91 } 88 92 89 93 public function test_get_items() { 90 $id1 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page' ) ); 91 $id2 = $this->factory->post->create( array( 'post_status' => 'draft', 'post_type' => 'page' ) ); 92 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); 93 $response = $this->server->dispatch( $request ); 94 $data = $response->get_data(); 94 $id1 = $this->factory->post->create( 95 array( 96 'post_status' => 'publish', 97 'post_type' => 'page', 98 ) 99 ); 100 $id2 = $this->factory->post->create( 101 array( 102 'post_status' => 'draft', 103 'post_type' => 'page', 104 ) 105 ); 106 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); 107 $response = $this->server->dispatch( $request ); 108 $data = $response->get_data(); 95 109 $this->assertEquals( 1, count( $data ) ); 96 110 $this->assertEquals( $id1, $data[0]['id'] ); … … 98 112 99 113 public function test_get_items_parent_query() { 100 $id1 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page' ) ); 101 $id2 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', 'post_parent' => $id1 ) ); 114 $id1 = $this->factory->post->create( 115 array( 116 'post_status' => 'publish', 117 'post_type' => 'page', 118 ) 119 ); 120 $id2 = $this->factory->post->create( 121 array( 122 'post_status' => 'publish', 123 'post_type' => 'page', 124 'post_parent' => $id1, 125 ) 126 ); 102 127 // No parent 103 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' );104 $response = $this->server->dispatch( $request ); 105 $data = $response->get_data();128 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); 129 $response = $this->server->dispatch( $request ); 130 $data = $response->get_data(); 106 131 $this->assertEquals( 2, count( $data ) ); 107 132 // Filter to parent 108 133 $request->set_param( 'parent', $id1 ); 109 134 $response = $this->server->dispatch( $request ); 110 $data = $response->get_data();135 $data = $response->get_data(); 111 136 $this->assertEquals( 1, count( $data ) ); 112 137 $this->assertEquals( $id2, $data[0]['id'] ); … … 118 143 119 144 public function test_get_items_parents_query() { 120 $id1 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page' ) ); 121 $id2 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', 'post_parent' => $id1 ) ); 122 $id3 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page' ) ); 123 $id4 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', 'post_parent' => $id3 ) ); 145 $id1 = $this->factory->post->create( 146 array( 147 'post_status' => 'publish', 148 'post_type' => 'page', 149 ) 150 ); 151 $id2 = $this->factory->post->create( 152 array( 153 'post_status' => 'publish', 154 'post_type' => 'page', 155 'post_parent' => $id1, 156 ) 157 ); 158 $id3 = $this->factory->post->create( 159 array( 160 'post_status' => 'publish', 161 'post_type' => 'page', 162 ) 163 ); 164 $id4 = $this->factory->post->create( 165 array( 166 'post_status' => 'publish', 167 'post_type' => 'page', 168 'post_parent' => $id3, 169 ) 170 ); 124 171 // No parent 125 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' );126 $response = $this->server->dispatch( $request ); 127 $data = $response->get_data();172 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); 173 $response = $this->server->dispatch( $request ); 174 $data = $response->get_data(); 128 175 $this->assertEquals( 4, count( $data ) ); 129 176 // Filter to parents 130 177 $request->set_param( 'parent', array( $id1, $id3 ) ); 131 178 $response = $this->server->dispatch( $request ); 132 $data = $response->get_data();179 $data = $response->get_data(); 133 180 $this->assertEquals( 2, count( $data ) ); 134 181 $this->assertEqualSets( array( $id2, $id4 ), wp_list_pluck( $data, 'id' ) ); … … 136 183 137 184 public function test_get_items_parent_exclude_query() { 138 $id1 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page' ) ); 139 $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', 'post_parent' => $id1 ) ); 185 $id1 = $this->factory->post->create( 186 array( 187 'post_status' => 'publish', 188 'post_type' => 'page', 189 ) 190 ); 191 $this->factory->post->create( 192 array( 193 'post_status' => 'publish', 194 'post_type' => 'page', 195 'post_parent' => $id1, 196 ) 197 ); 140 198 // No parent 141 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' );142 $response = $this->server->dispatch( $request ); 143 $data = $response->get_data();199 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); 200 $response = $this->server->dispatch( $request ); 201 $data = $response->get_data(); 144 202 $this->assertEquals( 2, count( $data ) ); 145 203 // Filter to parent 146 204 $request->set_param( 'parent_exclude', $id1 ); 147 205 $response = $this->server->dispatch( $request ); 148 $data = $response->get_data();206 $data = $response->get_data(); 149 207 $this->assertEquals( 1, count( $data ) ); 150 208 $this->assertEquals( $id1, $data[0]['id'] ); … … 156 214 157 215 public function test_get_items_menu_order_query() { 158 $id1 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page' ) ); 159 $id2 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', 'menu_order' => 2 ) ); 160 $id3 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', 'menu_order' => 3 ) ); 161 $id4 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page', 'menu_order' => 1 ) ); 216 $id1 = $this->factory->post->create( 217 array( 218 'post_status' => 'publish', 219 'post_type' => 'page', 220 ) 221 ); 222 $id2 = $this->factory->post->create( 223 array( 224 'post_status' => 'publish', 225 'post_type' => 'page', 226 'menu_order' => 2, 227 ) 228 ); 229 $id3 = $this->factory->post->create( 230 array( 231 'post_status' => 'publish', 232 'post_type' => 'page', 233 'menu_order' => 3, 234 ) 235 ); 236 $id4 = $this->factory->post->create( 237 array( 238 'post_status' => 'publish', 239 'post_type' => 'page', 240 'menu_order' => 1, 241 ) 242 ); 162 243 // No parent 163 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' );164 $response = $this->server->dispatch( $request ); 165 $data = $response->get_data();244 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); 245 $response = $this->server->dispatch( $request ); 246 $data = $response->get_data(); 166 247 $this->assertEqualSets( array( $id1, $id2, $id3, $id4 ), wp_list_pluck( $data, 'id' ) ); 167 248 // Filter to menu_order 168 249 $request->set_param( 'menu_order', 1 ); 169 250 $response = $this->server->dispatch( $request ); 170 $data = $response->get_data();251 $data = $response->get_data(); 171 252 $this->assertEqualSets( array( $id4 ), wp_list_pluck( $data, 'id' ) ); 172 253 // Order by menu order … … 175 256 $request->set_param( 'orderby', 'menu_order' ); 176 257 $response = $this->server->dispatch( $request ); 177 $data = $response->get_data();258 $data = $response->get_data(); 178 259 $this->assertEquals( $id1, $data[0]['id'] ); 179 260 $this->assertEquals( $id4, $data[1]['id'] ); … … 199 280 $response = $this->server->dispatch( $request ); 200 281 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 201 $data = $response->get_data();282 $data = $response->get_data(); 202 283 $first_error = array_shift( $data['data']['params'] ); 203 284 $this->assertContains( 'per_page must be between 1 (inclusive) and 100 (inclusive)', $first_error ); … … 207 288 // Private query vars inaccessible to unauthorized users 208 289 wp_set_current_user( 0 ); 209 $page_id = $this->factory->post->create( array( 'post_status' => 'publish', 'post_type' => 'page' ) ); 210 $draft_id = $this->factory->post->create( array( 'post_status' => 'draft', 'post_type' => 'page' ) ); 211 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); 290 $page_id = $this->factory->post->create( 291 array( 292 'post_status' => 'publish', 293 'post_type' => 'page', 294 ) 295 ); 296 $draft_id = $this->factory->post->create( 297 array( 298 'post_status' => 'draft', 299 'post_type' => 'page', 300 ) 301 ); 302 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); 212 303 $request->set_param( 'status', 'draft' ); 213 304 $response = $this->server->dispatch( $request ); … … 217 308 wp_set_current_user( self::$editor_id ); 218 309 $response = $this->server->dispatch( $request ); 219 $data = $response->get_data();310 $data = $response->get_data(); 220 311 $this->assertCount( 1, $data ); 221 312 $this->assertEquals( $draft_id, $data[0]['id'] ); … … 231 322 232 323 public function test_get_items_valid_date() { 233 $post1 = $this->factory->post->create( array( 'post_date' => '2016-01-15T00:00:00Z', 'post_type' => 'page' ) ); 234 $post2 = $this->factory->post->create( array( 'post_date' => '2016-01-16T00:00:00Z', 'post_type' => 'page' ) ); 235 $post3 = $this->factory->post->create( array( 'post_date' => '2016-01-17T00:00:00Z', 'post_type' => 'page' ) ); 324 $post1 = $this->factory->post->create( 325 array( 326 'post_date' => '2016-01-15T00:00:00Z', 327 'post_type' => 'page', 328 ) 329 ); 330 $post2 = $this->factory->post->create( 331 array( 332 'post_date' => '2016-01-16T00:00:00Z', 333 'post_type' => 'page', 334 ) 335 ); 336 $post3 = $this->factory->post->create( 337 array( 338 'post_date' => '2016-01-17T00:00:00Z', 339 'post_type' => 'page', 340 ) 341 ); 236 342 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); 237 343 $request->set_param( 'after', '2016-01-15T00:00:00Z' ); 238 344 $request->set_param( 'before', '2016-01-17T00:00:00Z' ); 239 345 $response = $this->server->dispatch( $request ); 240 $data = $response->get_data();346 $data = $response->get_data(); 241 347 $this->assertCount( 1, $data ); 242 348 $this->assertEquals( $post2, $data[0]['id'] ); … … 248 354 249 355 public function test_get_item_invalid_post_type() { 250 $post_id = $this->factory->post->create();251 $request = new WP_REST_Request( 'GET', '/wp/v2/pages/' . $post_id );356 $post_id = $this->factory->post->create(); 357 $request = new WP_REST_Request( 'GET', '/wp/v2/pages/' . $post_id ); 252 358 $response = $this->server->dispatch( $request ); 253 359 $this->assertEquals( 404, $response->get_status() ); … … 262 368 263 369 $request = new WP_REST_Request( 'POST', '/wp/v2/pages' ); 264 $params = $this->set_post_data( array( 265 'template' => 'page-my-test-template.php', 266 ) ); 370 $params = $this->set_post_data( 371 array( 372 'template' => 'page-my-test-template.php', 373 ) 374 ); 267 375 $request->set_body_params( $params ); 268 376 $response = $this->server->dispatch( $request ); 269 377 270 $data = $response->get_data();378 $data = $response->get_data(); 271 379 $new_post = get_post( $data['id'] ); 272 380 $this->assertEquals( 'page-my-test-template.php', $data['template'] ); … … 275 383 276 384 public function test_create_page_with_parent() { 277 $page_id = $this->factory->post->create( array( 278 'type' => 'page', 279 ) ); 385 $page_id = $this->factory->post->create( 386 array( 387 'type' => 'page', 388 ) 389 ); 280 390 wp_set_current_user( self::$editor_id ); 281 391 282 392 $request = new WP_REST_Request( 'POST', '/wp/v2/pages' ); 283 $params = $this->set_post_data( array( 284 'parent' => $page_id, 285 ) ); 393 $params = $this->set_post_data( 394 array( 395 'parent' => $page_id, 396 ) 397 ); 286 398 $request->set_body_params( $params ); 287 399 $response = $this->server->dispatch( $request ); … … 292 404 $this->assertArrayHasKey( 'up', $links ); 293 405 294 $data = $response->get_data();406 $data = $response->get_data(); 295 407 $new_post = get_post( $data['id'] ); 296 408 $this->assertEquals( $page_id, $data['parent'] ); … … 302 414 303 415 $request = new WP_REST_Request( 'POST', '/wp/v2/pages' ); 304 $params = $this->set_post_data( array( 305 'parent' => -1, 306 ) ); 416 $params = $this->set_post_data( 417 array( 418 'parent' => -1, 419 ) 420 ); 307 421 $request->set_body_params( $params ); 308 422 $response = $this->server->dispatch( $request ); … … 316 430 317 431 public function test_delete_item() { 318 $page_id = $this->factory->post->create( array( 319 'post_type' => 'page', 320 'post_title' => 'Deleted page', 321 ) ); 432 $page_id = $this->factory->post->create( 433 array( 434 'post_type' => 'page', 435 'post_title' => 'Deleted page', 436 ) 437 ); 322 438 wp_set_current_user( self::$editor_id ); 323 439 … … 337 453 338 454 public function test_get_pages_params() { 339 $this->factory->post->create_many( 8, array( 340 'post_type' => 'page', 341 ) ); 455 $this->factory->post->create_many( 456 8, array( 457 'post_type' => 'page', 458 ) 459 ); 342 460 343 461 $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); 344 $request->set_query_params( array( 345 'page' => 2, 346 'per_page' => 4, 347 ) ); 462 $request->set_query_params( 463 array( 464 'page' => 2, 465 'per_page' => 4, 466 ) 467 ); 348 468 $response = $this->server->dispatch( $request ); 349 469 … … 363 483 public function test_update_page_menu_order() { 364 484 365 $page_id = $this->factory->post->create( array( 366 'post_type' => 'page', 367 ) ); 485 $page_id = $this->factory->post->create( 486 array( 487 'post_type' => 'page', 488 ) 489 ); 368 490 369 491 wp_set_current_user( self::$editor_id ); … … 371 493 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/pages/%d', $page_id ) ); 372 494 373 $request->set_body_params( array( 374 'menu_order' => 1, 375 ) ); 495 $request->set_body_params( 496 array( 497 'menu_order' => 1, 498 ) 499 ); 376 500 $response = $this->server->dispatch( $request ); 377 501 … … 382 506 public function test_update_page_menu_order_to_zero() { 383 507 384 $page_id = $this->factory->post->create( array( 385 'post_type' => 'page', 386 'menu_order' => 1, 387 ) ); 508 $page_id = $this->factory->post->create( 509 array( 510 'post_type' => 'page', 511 'menu_order' => 1, 512 ) 513 ); 388 514 389 515 wp_set_current_user( self::$editor_id ); … … 391 517 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/pages/%d', $page_id ) ); 392 518 393 $request->set_body_params(array( 394 'menu_order' => 0, 395 )); 519 $request->set_body_params( 520 array( 521 'menu_order' => 0, 522 ) 523 ); 396 524 $response = $this->server->dispatch( $request ); 397 525 … … 401 529 402 530 public function test_update_page_parent_non_zero() { 403 $page_id1 = $this->factory->post->create( array( 404 'post_type' => 'page', 405 ) ); 406 $page_id2 = $this->factory->post->create( array( 407 'post_type' => 'page', 408 ) ); 531 $page_id1 = $this->factory->post->create( 532 array( 533 'post_type' => 'page', 534 ) 535 ); 536 $page_id2 = $this->factory->post->create( 537 array( 538 'post_type' => 'page', 539 ) 540 ); 409 541 wp_set_current_user( self::$editor_id ); 410 542 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/pages/%d', $page_id2 ) ); 411 $request->set_body_params( array( 412 'parent' => $page_id1, 413 ) ); 543 $request->set_body_params( 544 array( 545 'parent' => $page_id1, 546 ) 547 ); 414 548 $response = $this->server->dispatch( $request ); 415 549 $new_data = $response->get_data(); … … 418 552 419 553 public function test_update_page_parent_zero() { 420 $page_id1 = $this->factory->post->create( array( 421 'post_type' => 'page', 422 ) ); 423 $page_id2 = $this->factory->post->create( array( 424 'post_type' => 'page', 425 'post_parent' => $page_id1, 426 ) ); 554 $page_id1 = $this->factory->post->create( 555 array( 556 'post_type' => 'page', 557 ) 558 ); 559 $page_id2 = $this->factory->post->create( 560 array( 561 'post_type' => 'page', 562 'post_parent' => $page_id1, 563 ) 564 ); 427 565 wp_set_current_user( self::$editor_id ); 428 566 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/pages/%d', $page_id2 ) ); 429 $request->set_body_params( array( 430 'parent' => 0, 431 ) ); 567 $request->set_body_params( 568 array( 569 'parent' => 0, 570 ) 571 ); 432 572 $response = $this->server->dispatch( $request ); 433 573 $new_data = $response->get_data(); … … 436 576 437 577 public function test_get_page_with_password() { 438 $page_id = $this->factory->post->create( array( 439 'post_type' => 'page', 440 'post_password' => '$inthebananastand', 441 ) ); 442 443 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/pages/%d', $page_id ) ); 578 $page_id = $this->factory->post->create( 579 array( 580 'post_type' => 'page', 581 'post_password' => '$inthebananastand', 582 ) 583 ); 584 585 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/pages/%d', $page_id ) ); 444 586 $response = $this->server->dispatch( $request ); 445 587 … … 452 594 453 595 public function test_get_page_with_password_using_password() { 454 $page_id = $this->factory->post->create( array( 455 'post_type' => 'page', 456 'post_password' => '$inthebananastand', 457 'post_content' => 'Some secret content.', 458 'post_excerpt' => 'Some secret excerpt.', 459 ) ); 460 461 $page = get_post( $page_id ); 596 $page_id = $this->factory->post->create( 597 array( 598 'post_type' => 'page', 599 'post_password' => '$inthebananastand', 600 'post_content' => 'Some secret content.', 601 'post_excerpt' => 'Some secret excerpt.', 602 ) 603 ); 604 605 $page = get_post( $page_id ); 462 606 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/pages/%d', $page_id ) ); 463 607 $request->set_param( 'password', '$inthebananastand' ); … … 472 616 473 617 public function test_get_page_with_password_using_incorrect_password() { 474 $page_id = $this->factory->post->create( array( 475 'post_type' => 'page', 476 'post_password' => '$inthebananastand', 477 ) ); 478 479 $page = get_post( $page_id ); 618 $page_id = $this->factory->post->create( 619 array( 620 'post_type' => 'page', 621 'post_password' => '$inthebananastand', 622 ) 623 ); 624 625 $page = get_post( $page_id ); 480 626 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/pages/%d', $page_id ) ); 481 627 $request->set_param( 'password', 'wrongpassword' ); … … 486 632 487 633 public function test_get_page_with_password_without_permission() { 488 $page_id = $this->factory->post->create( array( 489 'post_type' => 'page', 490 'post_password' => '$inthebananastand', 491 'post_content' => 'Some secret content.', 492 'post_excerpt' => 'Some secret excerpt.', 493 ) ); 494 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/pages/%d', $page_id ) ); 495 $response = $this->server->dispatch( $request ); 496 $data = $response->get_data(); 634 $page_id = $this->factory->post->create( 635 array( 636 'post_type' => 'page', 637 'post_password' => '$inthebananastand', 638 'post_content' => 'Some secret content.', 639 'post_excerpt' => 'Some secret excerpt.', 640 ) 641 ); 642 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/pages/%d', $page_id ) ); 643 $response = $this->server->dispatch( $request ); 644 $data = $response->get_data(); 497 645 $this->assertEquals( '', $data['content']['rendered'] ); 498 646 $this->assertTrue( $data['content']['protected'] ); … … 502 650 503 651 public function test_get_item_schema() { 504 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages' );505 $response = $this->server->dispatch( $request );506 $data = $response->get_data();652 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages' ); 653 $response = $this->server->dispatch( $request ); 654 $data = $response->get_data(); 507 655 $properties = $data['schema']['properties']; 508 656 $this->assertEquals( 22, count( $properties ) ); … … 544 692 545 693 protected function set_post_data( $args = array() ) { 546 $args = parent::set_post_data( $args );694 $args = parent::set_post_data( $args ); 547 695 $args['type'] = 'page'; 548 696 return $args;
Note: See TracChangeset
for help on using the changeset viewer.