- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-autosaves-controller.php
r46586 r48937 141 141 $response = rest_get_server()->dispatch( $request ); 142 142 $data = $response->get_data(); 143 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );143 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 144 144 $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); 145 145 … … 148 148 $response = rest_get_server()->dispatch( $request ); 149 149 $data = $response->get_data(); 150 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );150 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 151 151 $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); 152 152 } … … 158 158 $keys = array_keys( $data['endpoints'][0]['args'] ); 159 159 sort( $keys ); 160 $this->assert Equals(160 $this->assertSame( 161 161 array( 162 162 'context', … … 172 172 $response = rest_get_server()->dispatch( $request ); 173 173 $data = $response->get_data(); 174 $this->assert Equals( 200, $response->get_status() );174 $this->assertSame( 200, $response->get_status() ); 175 175 $this->assertCount( 1, $data ); 176 176 177 $this->assert Equals( self::$autosave_post_id, $data[0]['id'] );177 $this->assertSame( self::$autosave_post_id, $data[0]['id'] ); 178 178 179 179 $this->check_get_autosave_response( $data[0], $this->post_autosave ); … … 208 208 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/autosaves/' . self::$autosave_post_id ); 209 209 $response = rest_get_server()->dispatch( $request ); 210 $this->assert Equals( 200, $response->get_status() );210 $this->assertSame( 200, $response->get_status() ); 211 211 $data = $response->get_data(); 212 212 … … 278 278 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/autosaves/' . self::$autosave_post_id ); 279 279 $response = rest_get_server()->dispatch( $request ); 280 $this->assert Equals( 200, $response->get_status() );280 $this->assertSame( 200, $response->get_status() ); 281 281 $this->check_get_autosave_response( $response, $this->post_autosave ); 282 282 } … … 287 287 $data = $response->get_data(); 288 288 $properties = $data['schema']['properties']; 289 $this->assert Equals( 13, count( $properties ) );289 $this->assertSame( 13, count( $properties ) ); 290 290 $this->assertArrayHasKey( 'author', $properties ); 291 291 $this->assertArrayHasKey( 'content', $properties ); … … 378 378 $new_data = $response->get_data(); 379 379 380 $this->assert Equals( $current_post->ID, $new_data['parent'] );381 $this->assert Equals( $current_post->post_title, $new_data['title']['raw'] );382 $this->assert Equals( $current_post->post_excerpt, $new_data['excerpt']['raw'] );380 $this->assertSame( $current_post->ID, $new_data['parent'] ); 381 $this->assertSame( $current_post->post_title, $new_data['title']['raw'] ); 382 $this->assertSame( $current_post->post_excerpt, $new_data['excerpt']['raw'] ); 383 383 384 384 // Updated post_content. … … 386 386 387 387 $autosave_post = wp_get_post_autosave( self::$post_id ); 388 $this->assert Equals( $autosave_data['title'], $autosave_post->post_title );389 $this->assert Equals( $autosave_data['content'], $autosave_post->post_content );390 $this->assert Equals( $autosave_data['excerpt'], $autosave_post->post_excerpt );388 $this->assertSame( $autosave_data['title'], $autosave_post->post_title ); 389 $this->assertSame( $autosave_data['content'], $autosave_post->post_content ); 390 $this->assertSame( $autosave_data['excerpt'], $autosave_post->post_excerpt ); 391 391 } 392 392 … … 415 415 $post = get_post( $post_id ); 416 416 417 $this->assert Equals( $post_id, $new_data['id'] );417 $this->assertSame( $post_id, $new_data['id'] ); 418 418 // The draft post should be updated. 419 $this->assert Equals( $autosave_data['content'], $new_data['content']['raw'] );420 $this->assert Equals( $autosave_data['title'], $new_data['title']['raw'] );421 $this->assert Equals( $autosave_data['content'], $post->post_content );422 $this->assert Equals( $autosave_data['title'], $post->post_title );419 $this->assertSame( $autosave_data['content'], $new_data['content']['raw'] ); 420 $this->assertSame( $autosave_data['title'], $new_data['title']['raw'] ); 421 $this->assertSame( $autosave_data['content'], $post->post_content ); 422 $this->assertSame( $autosave_data['title'], $post->post_title ); 423 423 424 424 // Not updated. 425 $this->assert Equals( $post_data['post_excerpt'], $post->post_excerpt );425 $this->assertSame( $post_data['post_excerpt'], $post->post_excerpt ); 426 426 427 427 wp_delete_post( $post_id ); … … 454 454 $current_post = get_post( $post_id ); 455 455 456 $this->assert Equals( $current_post->ID, $new_data['parent'] );456 $this->assertSame( $current_post->ID, $new_data['parent'] ); 457 457 458 458 // The draft post shouldn't change. 459 $this->assert Equals( $current_post->post_title, $post_data['post_title'] );460 $this->assert Equals( $current_post->post_content, $post_data['post_content'] );461 $this->assert Equals( $current_post->post_excerpt, $post_data['post_excerpt'] );459 $this->assertSame( $current_post->post_title, $post_data['post_title'] ); 460 $this->assertSame( $current_post->post_content, $post_data['post_content'] ); 461 $this->assertSame( $current_post->post_excerpt, $post_data['post_excerpt'] ); 462 462 463 463 $autosave_post = wp_get_post_autosave( $post_id ); 464 464 465 465 // No changes. 466 $this->assert Equals( $current_post->post_title, $autosave_post->post_title );467 $this->assert Equals( $current_post->post_excerpt, $autosave_post->post_excerpt );466 $this->assertSame( $current_post->post_title, $autosave_post->post_title ); 467 $this->assertSame( $current_post->post_excerpt, $autosave_post->post_excerpt ); 468 468 469 469 // Has changes. 470 $this->assert Equals( $autosave_data['content'], $autosave_post->post_content );470 $this->assertSame( $autosave_data['content'], $autosave_post->post_content ); 471 471 472 472 wp_delete_post( $post_id ); … … 497 497 498 498 $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); 499 $this->assert Equals( $schema, $data['schema']['properties']['my_custom_int'] );499 $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); 500 500 501 501 wp_set_current_user( 1 ); … … 530 530 531 531 $rendered_content = apply_filters( 'the_content', $autosave->post_content ); 532 $this->assert Equals( $rendered_content, $response['content']['rendered'] );533 534 $this->assert Equals( mysql_to_rfc3339( $autosave->post_date ), $response['date'] ); //@codingStandardsIgnoreLine535 $this->assert Equals( mysql_to_rfc3339( $autosave->post_date_gmt ), $response['date_gmt'] ); //@codingStandardsIgnoreLine532 $this->assertSame( $rendered_content, $response['content']['rendered'] ); 533 534 $this->assertSame( mysql_to_rfc3339( $autosave->post_date ), $response['date'] ); //@codingStandardsIgnoreLine 535 $this->assertSame( mysql_to_rfc3339( $autosave->post_date_gmt ), $response['date_gmt'] ); //@codingStandardsIgnoreLine 536 536 537 537 $rendered_guid = apply_filters( 'get_the_guid', $autosave->guid, $autosave->ID ); 538 $this->assert Equals( $rendered_guid, $response['guid']['rendered'] );539 540 $this->assert Equals( $autosave->ID, $response['id'] );541 $this->assert Equals( mysql_to_rfc3339( $autosave->post_modified ), $response['modified'] ); //@codingStandardsIgnoreLine542 $this->assert Equals( mysql_to_rfc3339( $autosave->post_modified_gmt ), $response['modified_gmt'] ); //@codingStandardsIgnoreLine543 $this->assert Equals( $autosave->post_name, $response['slug'] );538 $this->assertSame( $rendered_guid, $response['guid']['rendered'] ); 539 540 $this->assertSame( $autosave->ID, $response['id'] ); 541 $this->assertSame( mysql_to_rfc3339( $autosave->post_modified ), $response['modified'] ); //@codingStandardsIgnoreLine 542 $this->assertSame( mysql_to_rfc3339( $autosave->post_modified_gmt ), $response['modified_gmt'] ); //@codingStandardsIgnoreLine 543 $this->assertSame( $autosave->post_name, $response['slug'] ); 544 544 545 545 $rendered_title = get_the_title( $autosave->ID ); 546 $this->assert Equals( $rendered_title, $response['title']['rendered'] );546 $this->assertSame( $rendered_title, $response['title']['rendered'] ); 547 547 548 548 $parent = get_post( $autosave->post_parent ); … … 550 550 $parent_object = get_post_type_object( $parent->post_type ); 551 551 $parent_base = ! empty( $parent_object->rest_base ) ? $parent_object->rest_base : $parent_object->name; 552 $this->assert Equals( rest_url( '/wp/v2/' . $parent_base . '/' . $autosave->post_parent ), $links['parent'][0]['href'] );552 $this->assertSame( rest_url( '/wp/v2/' . $parent_base . '/' . $autosave->post_parent ), $links['parent'][0]['href'] ); 553 553 } 554 554 … … 561 561 $parent_post_id = wp_is_post_revision( $post->ID ); 562 562 563 $this->assert Equals( $post->ID, self::$autosave_post_id );564 $this->assert Equals( $parent_post_id, self::$post_id );563 $this->assertSame( $post->ID, self::$autosave_post_id ); 564 $this->assertSame( $parent_post_id, self::$post_id ); 565 565 } 566 566 … … 581 581 $data = $response->get_data(); 582 582 583 $this->assert Equals( self::$child_draft_page_id, $data['id'] );584 $this->assert Equals( self::$parent_page_id, $data['parent'] );583 $this->assertSame( self::$child_draft_page_id, $data['id'] ); 584 $this->assertSame( self::$parent_page_id, $data['parent'] ); 585 585 } 586 586
Note: See TracChangeset
for help on using the changeset viewer.