- Timestamp:
- 09/02/2020 12:35:36 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php
r47122 r48937 50 50 $response = rest_get_server()->dispatch( $request ); 51 51 $data = $response->get_data(); 52 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );53 $this->assert Equals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );52 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 53 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 54 54 // Single. 55 55 $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); … … 57 57 $response = rest_get_server()->dispatch( $request ); 58 58 $data = $response->get_data(); 59 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );60 $this->assert Equals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );59 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 60 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 61 61 } 62 62 … … 67 67 $keys = array_keys( $data['endpoints'][0]['args'] ); 68 68 sort( $keys ); 69 $this->assert Equals(69 $this->assertSame( 70 70 array( 71 71 'after', … … 108 108 $response = rest_get_server()->dispatch( $request ); 109 109 $data = $response->get_data(); 110 $this->assert Equals( 1, count( $data ) );111 $this->assert Equals( $id1, $data[0]['id'] );110 $this->assertSame( 1, count( $data ) ); 111 $this->assertSame( $id1, $data[0]['id'] ); 112 112 } 113 113 … … 131 131 $response = rest_get_server()->dispatch( $request ); 132 132 $data = $response->get_data(); 133 $this->assert Equals( 2, count( $data ) );133 $this->assertSame( 2, count( $data ) ); 134 134 135 135 // Filter to parent. … … 137 137 $response = rest_get_server()->dispatch( $request ); 138 138 $data = $response->get_data(); 139 $this->assert Equals( 1, count( $data ) );140 $this->assert Equals( $id2, $data[0]['id'] );139 $this->assertSame( 1, count( $data ) ); 140 $this->assertSame( $id2, $data[0]['id'] ); 141 141 142 142 // Invalid 'parent' should error. … … 178 178 $response = rest_get_server()->dispatch( $request ); 179 179 $data = $response->get_data(); 180 $this->assert Equals( 4, count( $data ) );180 $this->assertSame( 4, count( $data ) ); 181 181 182 182 // Filter to parents. … … 184 184 $response = rest_get_server()->dispatch( $request ); 185 185 $data = $response->get_data(); 186 $this->assert Equals( 2, count( $data ) );186 $this->assertSame( 2, count( $data ) ); 187 187 $this->assertEqualSets( array( $id2, $id4 ), wp_list_pluck( $data, 'id' ) ); 188 188 } … … 207 207 $response = rest_get_server()->dispatch( $request ); 208 208 $data = $response->get_data(); 209 $this->assert Equals( 2, count( $data ) );209 $this->assertSame( 2, count( $data ) ); 210 210 211 211 // Filter to parent. … … 213 213 $response = rest_get_server()->dispatch( $request ); 214 214 $data = $response->get_data(); 215 $this->assert Equals( 1, count( $data ) );216 $this->assert Equals( $id1, $data[0]['id'] );215 $this->assertSame( 1, count( $data ) ); 216 $this->assertSame( $id1, $data[0]['id'] ); 217 217 218 218 // Invalid 'parent_exclude' should error. … … 269 269 $response = rest_get_server()->dispatch( $request ); 270 270 $data = $response->get_data(); 271 $this->assert Equals( $id1, $data[0]['id'] );272 $this->assert Equals( $id4, $data[1]['id'] );273 $this->assert Equals( $id2, $data[2]['id'] );274 $this->assert Equals( $id3, $data[3]['id'] );271 $this->assertSame( $id1, $data[0]['id'] ); 272 $this->assertSame( $id4, $data[1]['id'] ); 273 $this->assertSame( $id2, $data[2]['id'] ); 274 $this->assertSame( $id3, $data[3]['id'] ); 275 275 276 276 // Invalid 'menu_order' should error. … … 323 323 $data = $response->get_data(); 324 324 $this->assertCount( 1, $data ); 325 $this->assert Equals( $draft_id, $data[0]['id'] );325 $this->assertSame( $draft_id, $data[0]['id'] ); 326 326 } 327 327 … … 359 359 $data = $response->get_data(); 360 360 $this->assertCount( 1, $data ); 361 $this->assert Equals( $post2, $data[0]['id'] );361 $this->assertSame( $post2, $data[0]['id'] ); 362 362 } 363 363 … … 370 370 $request = new WP_REST_Request( 'GET', '/wp/v2/pages/' . $post_id ); 371 371 $response = rest_get_server()->dispatch( $request ); 372 $this->assert Equals( 404, $response->get_status() );372 $this->assertSame( 404, $response->get_status() ); 373 373 } 374 374 … … 391 391 $data = $response->get_data(); 392 392 $new_post = get_post( $data['id'] ); 393 $this->assert Equals( 'page-my-test-template.php', $data['template'] );394 $this->assert Equals( 'page-my-test-template.php', get_page_template_slug( $new_post->ID ) );393 $this->assertSame( 'page-my-test-template.php', $data['template'] ); 394 $this->assertSame( 'page-my-test-template.php', get_page_template_slug( $new_post->ID ) ); 395 395 } 396 396 … … 412 412 $response = rest_get_server()->dispatch( $request ); 413 413 414 $this->assert Equals( 201, $response->get_status() );414 $this->assertSame( 201, $response->get_status() ); 415 415 416 416 $links = $response->get_links(); … … 419 419 $data = $response->get_data(); 420 420 $new_post = get_post( $data['id'] ); 421 $this->assert Equals( $page_id, $data['parent'] );422 $this->assert Equals( $page_id, $new_post->post_parent );421 $this->assertSame( $page_id, $data['parent'] ); 422 $this->assertSame( $page_id, $new_post->post_parent ); 423 423 } 424 424 … … 455 455 $response = rest_get_server()->dispatch( $request ); 456 456 457 $this->assert Equals( 200, $response->get_status() );457 $this->assertSame( 200, $response->get_status() ); 458 458 $data = $response->get_data(); 459 $this->assert Equals( 'Deleted page', $data['title']['raw'] );460 $this->assert Equals( 'trash', $data['status'] );459 $this->assertSame( 'Deleted page', $data['title']['raw'] ); 460 $this->assertSame( 'trash', $data['status'] ); 461 461 } 462 462 … … 479 479 $obj = get_post( $page_id ); 480 480 $response = $endpoint->prepare_item_for_response( $obj, $request ); 481 $this->assert Equals(481 $this->assertSame( 482 482 array( 483 483 'id', … … 505 505 $response = rest_get_server()->dispatch( $request ); 506 506 507 $this->assert Equals( 200, $response->get_status() );507 $this->assertSame( 200, $response->get_status() ); 508 508 509 509 $headers = $response->get_headers(); 510 $this->assert Equals( 8, $headers['X-WP-Total'] );511 $this->assert Equals( 2, $headers['X-WP-TotalPages'] );510 $this->assertSame( 8, $headers['X-WP-Total'] ); 511 $this->assertSame( 2, $headers['X-WP-TotalPages'] ); 512 512 513 513 $all_data = $response->get_data(); 514 $this->assert Equals( 4, count( $all_data ) );514 $this->assertSame( 4, count( $all_data ) ); 515 515 foreach ( $all_data as $post ) { 516 $this->assert Equals( 'page', $post['type'] );516 $this->assertSame( 'page', $post['type'] ); 517 517 } 518 518 } … … 538 538 539 539 $new_data = $response->get_data(); 540 $this->assert Equals( 1, $new_data['menu_order'] );540 $this->assertSame( 1, $new_data['menu_order'] ); 541 541 } 542 542 … … 562 562 563 563 $new_data = $response->get_data(); 564 $this->assert Equals( 0, $new_data['menu_order'] );564 $this->assertSame( 0, $new_data['menu_order'] ); 565 565 } 566 566 … … 585 585 $response = rest_get_server()->dispatch( $request ); 586 586 $new_data = $response->get_data(); 587 $this->assert Equals( $page_id1, $new_data['parent'] );587 $this->assertSame( $page_id1, $new_data['parent'] ); 588 588 } 589 589 … … 609 609 $response = rest_get_server()->dispatch( $request ); 610 610 $new_data = $response->get_data(); 611 $this->assert Equals( 0, $new_data['parent'] );611 $this->assertSame( 0, $new_data['parent'] ); 612 612 } 613 613 … … 624 624 625 625 $data = $response->get_data(); 626 $this->assert Equals( '', $data['content']['rendered'] );626 $this->assertSame( '', $data['content']['rendered'] ); 627 627 $this->assertTrue( $data['content']['protected'] ); 628 $this->assert Equals( '', $data['excerpt']['rendered'] );628 $this->assertSame( '', $data['excerpt']['rendered'] ); 629 629 $this->assertTrue( $data['excerpt']['protected'] ); 630 630 } … … 646 646 647 647 $data = $response->get_data(); 648 $this->assert Equals( wpautop( $page->post_content ), $data['content']['rendered'] );648 $this->assertSame( wpautop( $page->post_content ), $data['content']['rendered'] ); 649 649 $this->assertTrue( $data['content']['protected'] ); 650 $this->assert Equals( wpautop( $page->post_excerpt ), $data['excerpt']['rendered'] );650 $this->assertSame( wpautop( $page->post_excerpt ), $data['excerpt']['rendered'] ); 651 651 $this->assertTrue( $data['excerpt']['protected'] ); 652 652 } … … 680 680 $response = rest_get_server()->dispatch( $request ); 681 681 $data = $response->get_data(); 682 $this->assert Equals( '', $data['content']['rendered'] );682 $this->assertSame( '', $data['content']['rendered'] ); 683 683 $this->assertTrue( $data['content']['protected'] ); 684 $this->assert Equals( '', $data['excerpt']['rendered'] );684 $this->assertSame( '', $data['excerpt']['rendered'] ); 685 685 $this->assertTrue( $data['excerpt']['protected'] ); 686 686 } … … 691 691 $data = $response->get_data(); 692 692 $properties = $data['schema']['properties']; 693 $this->assert Equals( 24, count( $properties ) );693 $this->assertSame( 24, count( $properties ) ); 694 694 $this->assertArrayHasKey( 'author', $properties ); 695 695 $this->assertArrayHasKey( 'comment_status', $properties );
Note: See TracChangeset
for help on using the changeset viewer.