- 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-posts-controller.php
r48858 r48937 130 130 $expected_clause = str_replace( '{posts}', $wpdb->posts, $pattern ); 131 131 $this->assertCount( 1, $this->posts_clauses ); 132 $this->assert Equals( $expected_clause, $wpdb->remove_placeholder_escape( $this->posts_clauses[0][ $clause ] ) );132 $this->assertSame( $expected_clause, $wpdb->remove_placeholder_escape( $this->posts_clauses[0][ $clause ] ) ); 133 133 } 134 134 … … 155 155 $response = rest_get_server()->dispatch( $request ); 156 156 $data = $response->get_data(); 157 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );158 $this->assert Equals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );157 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 158 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 159 159 // Single. 160 160 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id ); 161 161 $response = rest_get_server()->dispatch( $request ); 162 162 $data = $response->get_data(); 163 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );164 $this->assert Equals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );163 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 164 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 165 165 } 166 166 … … 171 171 $keys = array_keys( $data['endpoints'][0]['args'] ); 172 172 sort( $keys ); 173 $this->assert Equals(173 $this->assertSame( 174 174 array( 175 175 'after', … … 205 205 $keys = array_keys( $data['endpoints'][0]['args'] ); 206 206 sort( $keys ); 207 $this->assert Equals( array( 'context', 'id', 'password' ), $keys );207 $this->assertSame( array( 'context', 'id', 'password' ), $keys ); 208 208 } 209 209 … … 218 218 219 219 $this->assertNotEmpty( $headers['Allow'] ); 220 $this->assert Equals( $headers['Allow'], 'GET' );220 $this->assertSame( $headers['Allow'], 'GET' ); 221 221 222 222 wp_set_current_user( self::$editor_id ); … … 228 228 229 229 $this->assertNotEmpty( $headers['Allow'] ); 230 $this->assert Equals( $headers['Allow'], 'GET, POST, PUT, PATCH, DELETE' );230 $this->assertSame( $headers['Allow'], 'GET, POST, PUT, PATCH, DELETE' ); 231 231 } 232 232 … … 253 253 254 254 $this->assertEmpty( $response->get_data() ); 255 $this->assert Equals( 200, $response->get_status() );255 $this->assertSame( 200, $response->get_status() ); 256 256 } 257 257 … … 266 266 $request->set_param( 'per_page', self::$per_page ); 267 267 $response = rest_get_server()->dispatch( $request ); 268 $this->assert Equals( 200, $response->get_status() );269 $this->assert Equals( $total_posts, count( $response->get_data() ) );268 $this->assertSame( 200, $response->get_status() ); 269 $this->assertSame( $total_posts, count( $response->get_data() ) ); 270 270 271 271 // Limit to editor and author. … … 273 273 $request->set_param( 'author', array( self::$editor_id, self::$author_id ) ); 274 274 $response = rest_get_server()->dispatch( $request ); 275 $this->assert Equals( 200, $response->get_status() );275 $this->assertSame( 200, $response->get_status() ); 276 276 $data = $response->get_data(); 277 $this->assert Equals( 2, count( $data ) );277 $this->assertSame( 2, count( $data ) ); 278 278 $this->assertEqualSets( array( self::$editor_id, self::$author_id ), wp_list_pluck( $data, 'author' ) ); 279 279 … … 282 282 $request->set_param( 'author', self::$editor_id ); 283 283 $response = rest_get_server()->dispatch( $request ); 284 $this->assert Equals( 200, $response->get_status() );284 $this->assertSame( 200, $response->get_status() ); 285 285 $data = $response->get_data(); 286 $this->assert Equals( 1, count( $data ) );287 $this->assert Equals( self::$editor_id, $data[0]['author'] );286 $this->assertSame( 1, count( $data ) ); 287 $this->assertSame( self::$editor_id, $data[0]['author'] ); 288 288 } 289 289 … … 298 298 $request->set_param( 'per_page', self::$per_page ); 299 299 $response = rest_get_server()->dispatch( $request ); 300 $this->assert Equals( 200, $response->get_status() );301 $this->assert Equals( $total_posts, count( $response->get_data() ) );300 $this->assertSame( 200, $response->get_status() ); 301 $this->assertSame( $total_posts, count( $response->get_data() ) ); 302 302 303 303 // Exclude editor and author. … … 306 306 $request->set_param( 'author_exclude', array( self::$editor_id, self::$author_id ) ); 307 307 $response = rest_get_server()->dispatch( $request ); 308 $this->assert Equals( 200, $response->get_status() );308 $this->assertSame( 200, $response->get_status() ); 309 309 $data = $response->get_data(); 310 $this->assert Equals( $total_posts - 2, count( $data ) );310 $this->assertSame( $total_posts - 2, count( $data ) ); 311 311 $this->assertNotEquals( self::$editor_id, $data[0]['author'] ); 312 312 $this->assertNotEquals( self::$author_id, $data[0]['author'] ); … … 317 317 $request->set_param( 'author_exclude', self::$editor_id ); 318 318 $response = rest_get_server()->dispatch( $request ); 319 $this->assert Equals( 200, $response->get_status() );319 $this->assertSame( 200, $response->get_status() ); 320 320 $data = $response->get_data(); 321 $this->assert Equals( $total_posts - 1, count( $data ) );321 $this->assertSame( $total_posts - 1, count( $data ) ); 322 322 $this->assertNotEquals( self::$editor_id, $data[0]['author'] ); 323 323 $this->assertNotEquals( self::$editor_id, $data[1]['author'] ); … … 350 350 $response = rest_get_server()->dispatch( $request ); 351 351 $data = $response->get_data(); 352 $this->assert Equals( 2, count( $data ) );353 $this->assert Equals( $id2, $data[0]['id'] );352 $this->assertSame( 2, count( $data ) ); 353 $this->assertSame( $id2, $data[0]['id'] ); 354 354 $this->assertPostsOrderedBy( '{posts}.post_date DESC' ); 355 355 … … 358 358 $response = rest_get_server()->dispatch( $request ); 359 359 $data = $response->get_data(); 360 $this->assert Equals( 2, count( $data ) );361 $this->assert Equals( $id1, $data[0]['id'] );360 $this->assertSame( 2, count( $data ) ); 361 $this->assertSame( $id1, $data[0]['id'] ); 362 362 $this->assertPostsOrderedBy( "FIELD({posts}.ID,$id1,$id2)" ); 363 363 … … 396 396 $data = $response->get_data(); 397 397 398 $this->assert Equals( 200, $response->get_status() );399 $this->assert Equals( self::$author_id, $data[0]['author'] );400 $this->assert Equals( self::$editor_id, $data[1]['author'] );401 $this->assert Equals( self::$editor_id, $data[2]['author'] );398 $this->assertSame( 200, $response->get_status() ); 399 $this->assertSame( self::$author_id, $data[0]['author'] ); 400 $this->assertSame( self::$editor_id, $data[1]['author'] ); 401 $this->assertSame( self::$editor_id, $data[2]['author'] ); 402 402 403 403 $this->assertPostsOrderedBy( '{posts}.post_author DESC' ); … … 420 420 $data = $response->get_data(); 421 421 422 $this->assert Equals( 200, $response->get_status() );423 $this->assert Equals( $id1, $data[0]['id'] );424 $this->assert Equals( $id3, $data[1]['id'] );425 $this->assert Equals( $id2, $data[2]['id'] );422 $this->assertSame( 200, $response->get_status() ); 423 $this->assertSame( $id1, $data[0]['id'] ); 424 $this->assertSame( $id3, $data[1]['id'] ); 425 $this->assertSame( $id2, $data[2]['id'] ); 426 426 427 427 $this->assertPostsOrderedBy( '{posts}.post_modified DESC' ); … … 456 456 $data = $response->get_data(); 457 457 458 $this->assert Equals( 200, $response->get_status() );459 $this->assert Equals( $id3, $data[0]['id'] );458 $this->assertSame( 200, $response->get_status() ); 459 $this->assertSame( $id3, $data[0]['id'] ); 460 460 // Check ordering. Default ORDER is DESC. 461 $this->assert Equals( $id1, $data[0]['parent'] );462 $this->assert Equals( 0, $data[1]['parent'] );463 $this->assert Equals( 0, $data[2]['parent'] );461 $this->assertSame( $id1, $data[0]['parent'] ); 462 $this->assertSame( 0, $data[1]['parent'] ); 463 $this->assertSame( 0, $data[2]['parent'] ); 464 464 465 465 $this->assertPostsOrderedBy( '{posts}.post_parent DESC' ); … … 508 508 $request->set_param( 'per_page', self::$per_page ); 509 509 $response = rest_get_server()->dispatch( $request ); 510 $this->assert Equals( $total_posts, count( $response->get_data() ) );510 $this->assertSame( $total_posts, count( $response->get_data() ) ); 511 511 512 512 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); … … 514 514 $response = rest_get_server()->dispatch( $request ); 515 515 $data = $response->get_data(); 516 $this->assert Equals( 1, count( $data ) );517 $this->assert Equals( 'Search Result', $data[0]['title']['rendered'] );516 $this->assertSame( 1, count( $data ) ); 517 $this->assertSame( 'Search Result', $data[0]['title']['rendered'] ); 518 518 } 519 519 … … 535 535 $request->set_param( 'slug', 'apple' ); 536 536 $response = rest_get_server()->dispatch( $request ); 537 $this->assert Equals( 200, $response->get_status() );537 $this->assertSame( 200, $response->get_status() ); 538 538 $data = $response->get_data(); 539 $this->assert Equals( 1, count( $data ) );540 $this->assert Equals( 'Apple', $data[0]['title']['rendered'] );539 $this->assertSame( 1, count( $data ) ); 540 $this->assertSame( 'Apple', $data[0]['title']['rendered'] ); 541 541 } 542 542 … … 564 564 $request->set_param( 'slug', array( 'banana', 'peach' ) ); 565 565 $response = rest_get_server()->dispatch( $request ); 566 $this->assert Equals( 200, $response->get_status() );566 $this->assertSame( 200, $response->get_status() ); 567 567 $data = $response->get_data(); 568 $this->assert Equals( 2, count( $data ) );568 $this->assertSame( 2, count( $data ) ); 569 569 $titles = array( 570 570 $data[0]['title']['rendered'], … … 572 572 ); 573 573 sort( $titles ); 574 $this->assert Equals( array( 'Banana', 'Peach' ), $titles );574 $this->assertSame( array( 'Banana', 'Peach' ), $titles ); 575 575 } 576 576 … … 598 598 $request->set_param( 'slug', 'apple,banana' ); 599 599 $response = rest_get_server()->dispatch( $request ); 600 $this->assert Equals( 200, $response->get_status() );600 $this->assertSame( 200, $response->get_status() ); 601 601 $data = $response->get_data(); 602 $this->assert Equals( 2, count( $data ) );602 $this->assertSame( 2, count( $data ) ); 603 603 $titles = array( 604 604 $data[0]['title']['rendered'], … … 606 606 ); 607 607 sort( $titles ); 608 $this->assert Equals( array( 'Apple', 'Banana' ), $titles );608 $this->assertSame( array( 'Apple', 'Banana' ), $titles ); 609 609 } 610 610 … … 618 618 $request->set_param( 'status', 'publish' ); 619 619 $response = rest_get_server()->dispatch( $request ); 620 $this->assert Equals( 200, $response->get_status() );621 $this->assert Equals( self::$total_posts, count( $response->get_data() ) );620 $this->assertSame( 200, $response->get_status() ); 621 $this->assertSame( self::$total_posts, count( $response->get_data() ) ); 622 622 623 623 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); … … 631 631 $request->set_param( 'status', 'draft' ); 632 632 $response = rest_get_server()->dispatch( $request ); 633 $this->assert Equals( 200, $response->get_status() );634 $this->assert Equals( 1, count( $response->get_data() ) );633 $this->assertSame( 200, $response->get_status() ); 634 $this->assertSame( 1, count( $response->get_data() ) ); 635 635 } 636 636 … … 647 647 648 648 $response = rest_get_server()->dispatch( $request ); 649 $this->assert Equals( 200, $response->get_status() );649 $this->assertSame( 200, $response->get_status() ); 650 650 $data = $response->get_data(); 651 $this->assert Equals( 2, count( $data ) );651 $this->assertSame( 2, count( $data ) ); 652 652 $statuses = array( 653 653 $data[0]['status'], … … 655 655 ); 656 656 sort( $statuses ); 657 $this->assert Equals( array( 'draft', 'private' ), $statuses );657 $this->assertSame( array( 'draft', 'private' ), $statuses ); 658 658 } 659 659 … … 670 670 671 671 $response = rest_get_server()->dispatch( $request ); 672 $this->assert Equals( 200, $response->get_status() );672 $this->assertSame( 200, $response->get_status() ); 673 673 $data = $response->get_data(); 674 $this->assert Equals( 2, count( $data ) );674 $this->assertSame( 2, count( $data ) ); 675 675 $statuses = array( 676 676 $data[0]['status'], … … 678 678 ); 679 679 sort( $statuses ); 680 $this->assert Equals( array( 'draft', 'pending' ), $statuses );680 $this->assertSame( array( 'draft', 'pending' ), $statuses ); 681 681 } 682 682 … … 725 725 $response = rest_get_server()->dispatch( $request ); 726 726 727 $this->assert Equals( 200, $response->get_status() );727 $this->assertSame( 200, $response->get_status() ); 728 728 729 729 $all_data = $response->get_data(); … … 766 766 $response = rest_get_server()->dispatch( $request ); 767 767 $data = $response->get_data(); 768 $this->assert Equals( 'Apple Sauce', $data[0]['title']['rendered'] );768 $this->assertSame( 'Apple Sauce', $data[0]['title']['rendered'] ); 769 769 $this->assertPostsOrderedBy( '{posts}.post_title DESC' ); 770 770 … … 773 773 $response = rest_get_server()->dispatch( $request ); 774 774 $data = $response->get_data(); 775 $this->assert Equals( 'Apple Cobbler', $data[0]['title']['rendered'] );775 $this->assertSame( 'Apple Cobbler', $data[0]['title']['rendered'] ); 776 776 $this->assertPostsOrderedBy( '{posts}.post_title ASC' ); 777 777 … … 827 827 828 828 // Default ORDER is DESC. 829 $this->assert Equals( $id3, $data[0]['id'] );830 $this->assert Equals( $id2, $data[1]['id'] );831 $this->assert Equals( $id1, $data[2]['id'] );829 $this->assertSame( $id3, $data[0]['id'] ); 830 $this->assertSame( $id2, $data[1]['id'] ); 831 $this->assertSame( $id1, $data[2]['id'] ); 832 832 $this->assertPostsOrderedBy( '{posts}.ID DESC' ); 833 833 } … … 857 857 858 858 // Default ORDER is DESC. 859 $this->assert Equals( 'xyz', $data[0]['slug'] );860 $this->assert Equals( 'abc', $data[1]['slug'] );859 $this->assertSame( 'xyz', $data[0]['slug'] ); 860 $this->assertSame( 'abc', $data[1]['slug'] ); 861 861 $this->assertPostsOrderedBy( '{posts}.post_name DESC' ); 862 862 } … … 881 881 $data = $response->get_data(); 882 882 883 $this->assert Equals( 'taco', $data[0]['slug'] );884 $this->assert Equals( 'chalupa', $data[1]['slug'] );885 $this->assert Equals( 'burrito', $data[2]['slug'] );883 $this->assertSame( 'taco', $data[0]['slug'] ); 884 $this->assertSame( 'chalupa', $data[1]['slug'] ); 885 $this->assertSame( 'burrito', $data[2]['slug'] ); 886 886 } 887 887 … … 906 906 $request->set_param( 'search', 'relevant' ); 907 907 $response = rest_get_server()->dispatch( $request ); 908 $this->assert Equals( 200, $response->get_status() );908 $this->assertSame( 200, $response->get_status() ); 909 909 $data = $response->get_data(); 910 910 $this->assertCount( 2, $data ); 911 $this->assert Equals( $id1, $data[0]['id'] );912 $this->assert Equals( $id2, $data[1]['id'] );911 $this->assertSame( $id1, $data[0]['id'] ); 912 $this->assertSame( $id2, $data[1]['id'] ); 913 913 $this->assertPostsOrderedBy( '{posts}.post_title LIKE \'%relevant%\' DESC, {posts}.post_date DESC' ); 914 914 } … … 934 934 $request->set_param( 'search', 'relevant content' ); 935 935 $response = rest_get_server()->dispatch( $request ); 936 $this->assert Equals( 200, $response->get_status() );936 $this->assertSame( 200, $response->get_status() ); 937 937 $data = $response->get_data(); 938 938 $this->assertCount( 2, $data ); 939 $this->assert Equals( $id1, $data[0]['id'] );940 $this->assert Equals( $id2, $data[1]['id'] );939 $this->assertSame( $id1, $data[0]['id'] ); 940 $this->assertSame( $id2, $data[1]['id'] ); 941 941 $this->assertPostsOrderedBy( '(CASE WHEN {posts}.post_title LIKE \'%relevant content%\' THEN 1 WHEN {posts}.post_title LIKE \'%relevant%\' AND {posts}.post_title LIKE \'%content%\' THEN 2 WHEN {posts}.post_title LIKE \'%relevant%\' OR {posts}.post_title LIKE \'%content%\' THEN 3 WHEN {posts}.post_excerpt LIKE \'%relevant content%\' THEN 4 WHEN {posts}.post_content LIKE \'%relevant content%\' THEN 5 ELSE 6 END), {posts}.post_date DESC' ); 942 942 } … … 984 984 $data = $response->get_data(); 985 985 $this->assertCount( 1, $data ); 986 $this->assert Equals( $id1, $data[0]['id'] );986 $this->assertSame( $id1, $data[0]['id'] ); 987 987 } 988 988 … … 1005 1005 $data = $response->get_data(); 1006 1006 $this->assertCount( $total_posts - 1, $data ); 1007 $this->assert Equals( $id4, $data[0]['id'] );1008 $this->assert Equals( $id3, $data[1]['id'] );1009 $this->assert Equals( $id2, $data[2]['id'] );1007 $this->assertSame( $id4, $data[0]['id'] ); 1008 $this->assertSame( $id3, $data[1]['id'] ); 1009 $this->assertSame( $id2, $data[2]['id'] ); 1010 1010 } 1011 1011 … … 1053 1053 $data = $response->get_data(); 1054 1054 $this->assertCount( 2, $data ); 1055 $this->assert Equals( $id2, $data[0]['id'] );1056 $this->assert Equals( $id1, $data[1]['id'] );1055 $this->assertSame( $id2, $data[0]['id'] ); 1056 $this->assertSame( $id1, $data[1]['id'] ); 1057 1057 } 1058 1058 … … 1074 1074 $data = $response->get_data(); 1075 1075 $this->assertCount( 1, $data ); 1076 $this->assert Equals( $id2, $data[0]['id'] );1076 $this->assertSame( $id2, $data[0]['id'] ); 1077 1077 1078 1078 $request->set_param( 'tags_exclude', array( 'my-tag' ) ); … … 1109 1109 $data = $response->get_data(); 1110 1110 $this->assertCount( $total_posts - 1, $data ); 1111 $this->assert Equals( $id4, $data[0]['id'] );1112 $this->assert Equals( $id2, $data[1]['id'] );1113 $this->assert Equals( $id1, $data[2]['id'] );1111 $this->assertSame( $id4, $data[0]['id'] ); 1112 $this->assertSame( $id2, $data[1]['id'] ); 1113 $this->assertSame( $id1, $data[2]['id'] ); 1114 1114 } 1115 1115 … … 1123 1123 1124 1124 $response = rest_get_server()->dispatch( $request ); 1125 $this->assert Equals( 200, $response->get_status() );1125 $this->assertSame( 200, $response->get_status() ); 1126 1126 $this->assertCount( 1, $response->get_data() ); 1127 $this->assert Equals( self::$post_id, $response->get_data()[0]['id'] );1127 $this->assertSame( self::$post_id, $response->get_data()[0]['id'] ); 1128 1128 } 1129 1129 … … 1142 1142 $posts = $response->get_data(); 1143 1143 $post = $posts[0]; 1144 $this->assert Equals( $id2, $post['id'] );1144 $this->assertSame( $id2, $post['id'] ); 1145 1145 1146 1146 $request->set_param( 'sticky', 'nothanks' ); … … 1180 1180 $posts = $response->get_data(); 1181 1181 $post = $posts[0]; 1182 $this->assert Equals( $id1, $post['id'] );1182 $this->assertSame( $id1, $post['id'] ); 1183 1183 1184 1184 $this->assertPostsWhere( " AND {posts}.ID IN ($id1) AND {posts}.post_type = 'post' AND (({posts}.post_status = 'publish'))" ); … … 1237 1237 $posts = $response->get_data(); 1238 1238 $post = $posts[0]; 1239 $this->assert Equals( $id1, $post['id'] );1239 $this->assertSame( $id1, $post['id'] ); 1240 1240 1241 1241 $this->assertPostsWhere( " AND {posts}.ID NOT IN ($id2) AND {posts}.post_type = 'post' AND (({posts}.post_status = 'publish'))" ); … … 1302 1302 $response = rest_get_server()->dispatch( $request ); 1303 1303 $headers = $response->get_headers(); 1304 $this->assert Equals( $total_posts, $headers['X-WP-Total'] );1305 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );1304 $this->assertSame( $total_posts, $headers['X-WP-Total'] ); 1305 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 1306 1306 $next_link = add_query_arg( 1307 1307 array( … … 1321 1321 $response = rest_get_server()->dispatch( $request ); 1322 1322 $headers = $response->get_headers(); 1323 $this->assert Equals( $total_posts, $headers['X-WP-Total'] );1324 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );1323 $this->assertSame( $total_posts, $headers['X-WP-Total'] ); 1324 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 1325 1325 $prev_link = add_query_arg( 1326 1326 array( … … 1343 1343 $response = rest_get_server()->dispatch( $request ); 1344 1344 $headers = $response->get_headers(); 1345 $this->assert Equals( $total_posts, $headers['X-WP-Total'] );1346 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );1345 $this->assertSame( $total_posts, $headers['X-WP-Total'] ); 1346 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 1347 1347 $prev_link = add_query_arg( 1348 1348 array( … … 1372 1372 $response = rest_get_server()->dispatch( $request ); 1373 1373 $headers = $response->get_headers(); 1374 $this->assert Equals( $total_posts, $headers['X-WP-Total'] );1375 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );1374 $this->assertSame( $total_posts, $headers['X-WP-Total'] ); 1375 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 1376 1376 $prev_link = add_query_arg( 1377 1377 array( … … 1416 1416 $response = rest_get_server()->dispatch( $request ); 1417 1417 $data = $response->get_data(); 1418 $this->assert Equals( $draft_id, $data[0]['id'] );1418 $this->assertSame( $draft_id, $data[0]['id'] ); 1419 1419 } 1420 1420 … … 1439 1439 $response = rest_get_server()->dispatch( $request ); 1440 1440 $data = $response->get_data(); 1441 $this->assert Equals( 200, $response->get_status() );1441 $this->assertSame( 200, $response->get_status() ); 1442 1442 $this->assertCount( 1, $data ); 1443 $this->assert Equals( $private_post_id, $data[0]['id'] );1443 $this->assertSame( $private_post_id, $data[0]['id'] ); 1444 1444 } 1445 1445 … … 1488 1488 $data = $response->get_data(); 1489 1489 $this->assertCount( 1, $data ); 1490 $this->assert Equals( $post2, $data[0]['id'] );1490 $this->assertSame( $post2, $data[0]['id'] ); 1491 1491 } 1492 1492 … … 1498 1498 $formats = array_values( get_post_format_slugs() ); 1499 1499 1500 $this->assert Equals( $formats, $data['schema']['properties']['format']['enum'] );1500 $this->assertSame( $formats, $data['schema']['properties']['format']['enum'] ); 1501 1501 } 1502 1502 … … 1514 1514 $links = $response->get_links(); 1515 1515 1516 $this->assert Equals( rest_url( '/wp/v2/posts/' . self::$post_id ), $links['self'][0]['href'] );1517 $this->assert Equals( rest_url( '/wp/v2/posts' ), $links['collection'][0]['href'] );1516 $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id ), $links['self'][0]['href'] ); 1517 $this->assertSame( rest_url( '/wp/v2/posts' ), $links['collection'][0]['href'] ); 1518 1518 $this->assertArrayNotHasKey( 'embeddable', $links['self'][0]['attributes'] ); 1519 1519 1520 $this->assert Equals( rest_url( '/wp/v2/types/' . get_post_type( self::$post_id ) ), $links['about'][0]['href'] );1520 $this->assertSame( rest_url( '/wp/v2/types/' . get_post_type( self::$post_id ) ), $links['about'][0]['href'] ); 1521 1521 1522 1522 $replies_url = rest_url( '/wp/v2/comments' ); 1523 1523 $replies_url = add_query_arg( 'post', self::$post_id, $replies_url ); 1524 $this->assert Equals( $replies_url, $links['replies'][0]['href'] );1525 1526 $this->assert Equals( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] );1527 $this->assert Equals( 0, $links['version-history'][0]['attributes']['count'] );1524 $this->assertSame( $replies_url, $links['replies'][0]['href'] ); 1525 1526 $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] ); 1527 $this->assertSame( 0, $links['version-history'][0]['attributes']['count'] ); 1528 1528 $this->assertFalse( isset( $links['predecessor-version'] ) ); 1529 1529 1530 1530 $attachments_url = rest_url( '/wp/v2/media' ); 1531 1531 $attachments_url = add_query_arg( 'parent', self::$post_id, $attachments_url ); 1532 $this->assert Equals( $attachments_url, $links['https://api.w.org/attachment'][0]['href'] );1532 $this->assertSame( $attachments_url, $links['https://api.w.org/attachment'][0]['href'] ); 1533 1533 1534 1534 $term_links = $links['https://api.w.org/term']; … … 1550 1550 1551 1551 $tags_url = add_query_arg( 'post', self::$post_id, rest_url( '/wp/v2/tags' ) ); 1552 $this->assert Equals( $tags_url, $tag_link['href'] );1552 $this->assertSame( $tags_url, $tag_link['href'] ); 1553 1553 1554 1554 $category_url = add_query_arg( 'post', self::$post_id, rest_url( '/wp/v2/categories' ) ); 1555 $this->assert Equals( $category_url, $cat_link['href'] );1555 $this->assertSame( $category_url, $cat_link['href'] ); 1556 1556 } 1557 1557 … … 1571 1571 $links = $response->get_links(); 1572 1572 1573 $this->assert Equals( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] );1574 $this->assert Equals( 1, $links['version-history'][0]['attributes']['count'] );1575 1576 $this->assert Equals( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions/' . $revision_1->ID ), $links['predecessor-version'][0]['href'] );1577 $this->assert Equals( $revision_1->ID, $links['predecessor-version'][0]['attributes']['id'] );1573 $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] ); 1574 $this->assertSame( 1, $links['version-history'][0]['attributes']['count'] ); 1575 1576 $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions/' . $revision_1->ID ), $links['predecessor-version'][0]['href'] ); 1577 $this->assertSame( $revision_1->ID, $links['predecessor-version'][0]['attributes']['id'] ); 1578 1578 } 1579 1579 … … 1592 1592 $response = rest_get_server()->dispatch( $request ); 1593 1593 $links = $response->get_links(); 1594 $this->assert Equals( rest_url( '/wp/v2/users/' . self::$author_id ), $links['author'][0]['href'] );1594 $this->assertSame( rest_url( '/wp/v2/users/' . self::$author_id ), $links['author'][0]['href'] ); 1595 1595 } 1596 1596 … … 1673 1673 1674 1674 $data = $response->get_data(); 1675 $this->assert Equals( '', $data['content']['rendered'] );1675 $this->assertSame( '', $data['content']['rendered'] ); 1676 1676 $this->assertTrue( $data['content']['protected'] ); 1677 $this->assert Equals( '', $data['excerpt']['rendered'] );1677 $this->assertSame( '', $data['excerpt']['rendered'] ); 1678 1678 $this->assertTrue( $data['excerpt']['protected'] ); 1679 1679 } … … 1697 1697 1698 1698 $data = $response->get_data(); 1699 $this->assert Equals( wpautop( $post->post_content ), $data['content']['rendered'] );1699 $this->assertSame( wpautop( $post->post_content ), $data['content']['rendered'] ); 1700 1700 $this->assertTrue( $data['content']['protected'] ); 1701 $this->assert Equals( wpautop( $post->post_excerpt ), $data['excerpt']['rendered'] );1701 $this->assertSame( wpautop( $post->post_excerpt ), $data['excerpt']['rendered'] ); 1702 1702 $this->assertTrue( $data['excerpt']['protected'] ); 1703 1703 } … … 1732 1732 $data = $response->get_data(); 1733 1733 $this->check_get_post_response( $response, 'view' ); 1734 $this->assert Equals( '', $data['content']['rendered'] );1734 $this->assertSame( '', $data['content']['rendered'] ); 1735 1735 $this->assertTrue( $data['content']['protected'] ); 1736 $this->assert Equals( '', $data['excerpt']['rendered'] );1736 $this->assertSame( '', $data['excerpt']['rendered'] ); 1737 1737 $this->assertTrue( $data['excerpt']['protected'] ); 1738 1738 } … … 1812 1812 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); 1813 1813 $response = rest_get_server()->dispatch( $request ); 1814 $this->assert Equals( 200, $response->get_status() );1814 $this->assertSame( 200, $response->get_status() ); 1815 1815 1816 1816 // Private status. … … 1824 1824 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); 1825 1825 $response = rest_get_server()->dispatch( $request ); 1826 $this->assert Equals( 401, $response->get_status() );1826 $this->assertSame( 401, $response->get_status() ); 1827 1827 } 1828 1828 … … 1846 1846 $obj = get_post( self::$post_id ); 1847 1847 $response = $endpoint->prepare_item_for_response( $obj, $request ); 1848 $this->assert Equals(1848 $this->assertSame( 1849 1849 array( 1850 1850 'id', … … 1879 1879 remove_filter( 'the_content', $filter_content ); 1880 1880 1881 $this->assert Equals(1881 $this->assertSame( 1882 1882 array( 1883 1883 'id' => self::$post_id, … … 1915 1915 remove_filter( 'the_content', $filter_content ); 1916 1916 1917 $this->assert Equals(1917 $this->assertSame( 1918 1918 array( 1919 1919 'id' => $post->ID, … … 2030 2030 update_option( 'timezone_string', '' ); 2031 2031 2032 $this->assert Equals( 201, $response->get_status() );2032 $this->assertSame( 201, $response->get_status() ); 2033 2033 $data = $response->get_data(); 2034 2034 $post = get_post( $data['id'] ); 2035 2035 2036 $this->assert Equals( $results['date'], $data['date'] );2036 $this->assertSame( $results['date'], $data['date'] ); 2037 2037 $post_date = str_replace( 'T', ' ', $results['date'] ); 2038 $this->assert Equals( $post_date, $post->post_date );2039 2040 $this->assert Equals( $results['date_gmt'], $data['date_gmt'] );2038 $this->assertSame( $post_date, $post->post_date ); 2039 2040 $this->assertSame( $results['date_gmt'], $data['date_gmt'] ); 2041 2041 $post_date_gmt = str_replace( 'T', ' ', $results['date_gmt'] ); 2042 $this->assert Equals( $post_date_gmt, $post->post_date_gmt );2042 $this->assertSame( $post_date_gmt, $post->post_date_gmt ); 2043 2043 } 2044 2044 … … 2071 2071 remove_filter( 'theme_post_templates', array( $this, 'filter_theme_post_templates' ) ); 2072 2072 2073 $this->assert Equals( 'post-my-test-template.php', $data['template'] );2074 $this->assert Equals( 'post-my-test-template.php', $post_template );2073 $this->assertSame( 'post-my-test-template.php', $data['template'] ); 2074 $this->assertSame( 'post-my-test-template.php', $post_template ); 2075 2075 } 2076 2076 … … 2114 2114 $post_template = get_page_template_slug( get_post( $data['id'] ) ); 2115 2115 2116 $this->assert Equals( '', $data['template'] );2117 $this->assert Equals( '', $post_template );2116 $this->assertSame( '', $data['template'] ); 2117 $this->assertSame( '', $post_template ); 2118 2118 } 2119 2119 … … 2161 2161 $request->set_body_params( $params ); 2162 2162 $response = rest_get_server()->dispatch( $request ); 2163 $this->assert Equals( 201, $response->get_status() );2163 $this->assertSame( 201, $response->get_status() ); 2164 2164 2165 2165 $data = $response->get_data(); 2166 2166 $post = get_post( $data['id'] ); 2167 $this->assert Equals( '0000-00-00 00:00:00', $post->post_date_gmt );2167 $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); 2168 2168 $this->assertNotEquals( '0000-00-00T00:00:00', $data['date_gmt'] ); 2169 2169 … … 2186 2186 2187 2187 $new_data = $response->get_data(); 2188 $this->assert Equals( true,$new_data['sticky'] );2188 $this->assertTrue( $new_data['sticky'] ); 2189 2189 $post = get_post( $new_data['id'] ); 2190 $this->assert Equals( true,is_sticky( $post->ID ) );2190 $this->assertTrue( is_sticky( $post->ID ) ); 2191 2191 } 2192 2192 … … 2251 2251 $data = $response->get_data(); 2252 2252 $new_post = get_post( $data['id'] ); 2253 $this->assert Equals( 'draft', $data['status'] );2254 $this->assert Equals( 'draft', $new_post->post_status );2253 $this->assertSame( 'draft', $data['status'] ); 2254 $this->assertSame( 'draft', $new_post->post_status ); 2255 2255 // Confirm dates are shimmed for gmt_offset. 2256 2256 $post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $new_post->post_modified ) + ( get_option( 'gmt_offset' ) * 3600 ) ); 2257 2257 $post_date_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $new_post->post_date ) + ( get_option( 'gmt_offset' ) * 3600 ) ); 2258 2258 2259 $this->assert Equals( mysql_to_rfc3339( $post_modified_gmt ), $data['modified_gmt'] );2260 $this->assert Equals( mysql_to_rfc3339( $post_date_gmt ), $data['date_gmt'] );2259 $this->assertSame( mysql_to_rfc3339( $post_modified_gmt ), $data['modified_gmt'] ); 2260 $this->assertSame( mysql_to_rfc3339( $post_date_gmt ), $data['date_gmt'] ); 2261 2261 } 2262 2262 … … 2275 2275 $data = $response->get_data(); 2276 2276 $new_post = get_post( $data['id'] ); 2277 $this->assert Equals( 'private', $data['status'] );2278 $this->assert Equals( 'private', $new_post->post_status );2277 $this->assertSame( 'private', $data['status'] ); 2278 $this->assertSame( 'private', $new_post->post_status ); 2279 2279 } 2280 2280 … … 2351 2351 $data = $response->get_data(); 2352 2352 $new_post = get_post( $data['id'] ); 2353 $this->assert Equals( 'gallery', $data['format'] );2354 $this->assert Equals( 'gallery', get_post_format( $new_post->ID ) );2353 $this->assertSame( 'gallery', $data['format'] ); 2354 $this->assertSame( 'gallery', get_post_format( $new_post->ID ) ); 2355 2355 } 2356 2356 … … 2369 2369 $data = $response->get_data(); 2370 2370 $new_post = get_post( $data['id'] ); 2371 $this->assert Equals( 'standard', $data['format'] );2371 $this->assertSame( 'standard', $data['format'] ); 2372 2372 $this->assertFalse( get_post_format( $new_post->ID ) ); 2373 2373 } … … 2404 2404 $request->set_body_params( $params ); 2405 2405 $response = rest_get_server()->dispatch( $request ); 2406 $this->assert Equals( 201, $response->get_status() );2406 $this->assertSame( 201, $response->get_status() ); 2407 2407 2408 2408 $data = $response->get_data(); 2409 $this->assert Equals( 'link', $data['format'] );2409 $this->assertSame( 'link', $data['format'] ); 2410 2410 } 2411 2411 … … 2434 2434 $data = $response->get_data(); 2435 2435 $new_post = get_post( $data['id'] ); 2436 $this->assert Equals( $this->attachment_id, $data['featured_media'] );2437 $this->assert Equals( $this->attachment_id, (int) get_post_thumbnail_id( $new_post->ID ) );2436 $this->assertSame( $this->attachment_id, $data['featured_media'] ); 2437 $this->assertSame( $this->attachment_id, (int) get_post_thumbnail_id( $new_post->ID ) ); 2438 2438 2439 2439 $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . $new_post->ID ); … … 2446 2446 $response = rest_get_server()->dispatch( $request ); 2447 2447 $data = $response->get_data(); 2448 $this->assert Equals( 0, $data['featured_media'] );2449 $this->assert Equals( 0, (int) get_post_thumbnail_id( $new_post->ID ) );2448 $this->assertSame( 0, $data['featured_media'] ); 2449 $this->assertSame( 0, (int) get_post_thumbnail_id( $new_post->ID ) ); 2450 2450 } 2451 2451 … … 2493 2493 2494 2494 $data = $response->get_data(); 2495 $this->assert Equals( 'testing', $data['password'] );2495 $this->assertSame( 'testing', $data['password'] ); 2496 2496 } 2497 2497 … … 2509 2509 2510 2510 $data = $response->get_data(); 2511 $this->assert Equals( '0', $data['password'] );2511 $this->assertSame( '0', $data['password'] ); 2512 2512 } 2513 2513 … … 2525 2525 $response = rest_get_server()->dispatch( $request ); 2526 2526 2527 $this->assert Equals( 201, $response->get_status() );2527 $this->assertSame( 201, $response->get_status() ); 2528 2528 $data = $response->get_data(); 2529 $this->assert Equals( '', $data['password'] );2529 $this->assertSame( '', $data['password'] ); 2530 2530 } 2531 2531 … … 2561 2561 $new_post = get_post( $data['id'] ); 2562 2562 $time = gmmktime( 2, 0, 0, 1, 1, 2010 ); 2563 $this->assert Equals( '2010-01-01T02:00:00', $data['date'] );2564 $this->assert Equals( $time, strtotime( $new_post->post_date ) );2563 $this->assertSame( '2010-01-01T02:00:00', $data['date'] ); 2564 $this->assertSame( $time, strtotime( $new_post->post_date ) ); 2565 2565 } 2566 2566 … … 2581 2581 $time = gmmktime( 12, 0, 0, 1, 1, 2010 ); 2582 2582 2583 $this->assert Equals( '2010-01-01T12:00:00', $data['date'] );2584 $this->assert Equals( '2010-01-01T12:00:00', $data['modified'] );2585 2586 $this->assert Equals( $time, strtotime( $new_post->post_date ) );2587 $this->assert Equals( $time, strtotime( $new_post->post_modified ) );2583 $this->assertSame( '2010-01-01T12:00:00', $data['date'] ); 2584 $this->assertSame( '2010-01-01T12:00:00', $data['modified'] ); 2585 2586 $this->assertSame( $time, strtotime( $new_post->post_date ) ); 2587 $this->assertSame( $time, strtotime( $new_post->post_modified ) ); 2588 2588 } 2589 2589 … … 2653 2653 2654 2654 $data = $response->get_data(); 2655 $this->assert Equals( "Rob O'Rourke's Diary", $data['title']['raw'] );2655 $this->assertSame( "Rob O'Rourke's Diary", $data['title']['raw'] ); 2656 2656 } 2657 2657 … … 2674 2674 2675 2675 $data = $response->get_data(); 2676 $this->assert Equals( array( $category['term_id'] ), $data['categories'] );2676 $this->assertSame( array( $category['term_id'] ), $data['categories'] ); 2677 2677 } 2678 2678 … … 2693 2693 2694 2694 $data = $response->get_data(); 2695 $this->assert Equals( array( $category['term_id'], $category2['term_id'] ), $data['categories'] );2695 $this->assertSame( array( $category['term_id'], $category2['term_id'] ), $data['categories'] ); 2696 2696 } 2697 2697 … … 2712 2712 2713 2713 $data = $response->get_data(); 2714 $this->assert Equals( array(), $data['categories'] );2714 $this->assertSame( array(), $data['categories'] ); 2715 2715 } 2716 2716 … … 2758 2758 $this->check_update_post_response( $response ); 2759 2759 $new_data = $response->get_data(); 2760 $this->assert Equals( self::$post_id, $new_data['id'] );2761 $this->assert Equals( $params['title'], $new_data['title']['raw'] );2762 $this->assert Equals( $params['content'], $new_data['content']['raw'] );2763 $this->assert Equals( $params['excerpt'], $new_data['excerpt']['raw'] );2760 $this->assertSame( self::$post_id, $new_data['id'] ); 2761 $this->assertSame( $params['title'], $new_data['title']['raw'] ); 2762 $this->assertSame( $params['content'], $new_data['content']['raw'] ); 2763 $this->assertSame( $params['excerpt'], $new_data['excerpt']['raw'] ); 2764 2764 $post = get_post( self::$post_id ); 2765 $this->assert Equals( $params['title'], $post->post_title );2766 $this->assert Equals( $params['content'], $post->post_content );2767 $this->assert Equals( $params['excerpt'], $post->post_excerpt );2765 $this->assertSame( $params['title'], $post->post_title ); 2766 $this->assertSame( $params['content'], $post->post_content ); 2767 $this->assertSame( $params['excerpt'], $post->post_excerpt ); 2768 2768 } 2769 2769 … … 2796 2796 $this->check_update_post_response( $response ); 2797 2797 $new_data = $response->get_data(); 2798 $this->assert Equals( self::$post_id, $new_data['id'] );2799 $this->assert Equals( $params['title'], $new_data['title']['raw'] );2800 $this->assert Equals( $params['content'], $new_data['content']['raw'] );2801 $this->assert Equals( $params['excerpt'], $new_data['excerpt']['raw'] );2798 $this->assertSame( self::$post_id, $new_data['id'] ); 2799 $this->assertSame( $params['title'], $new_data['title']['raw'] ); 2800 $this->assertSame( $params['content'], $new_data['content']['raw'] ); 2801 $this->assertSame( $params['excerpt'], $new_data['excerpt']['raw'] ); 2802 2802 $post = get_post( self::$post_id ); 2803 $this->assert Equals( $params['title'], $post->post_title );2804 $this->assert Equals( $params['content'], $post->post_content );2805 $this->assert Equals( $params['excerpt'], $post->post_excerpt );2803 $this->assertSame( $params['title'], $post->post_title ); 2804 $this->assertSame( $params['content'], $post->post_content ); 2805 $this->assertSame( $params['excerpt'], $post->post_excerpt ); 2806 2806 } 2807 2807 … … 2838 2838 2839 2839 // Verify the post is set to the future date. 2840 $this->assert Equals( $new_data['date_gmt'], $future_date );2841 $this->assert Equals( $new_data['date'], $future_date );2840 $this->assertSame( $new_data['date_gmt'], $future_date ); 2841 $this->assertSame( $new_data['date'], $future_date ); 2842 2842 $this->assertNotEquals( $new_data['date_gmt'], $new_data['modified_gmt'] ); 2843 2843 $this->assertNotEquals( $new_data['date'], $new_data['modified'] ); … … 2859 2859 $this->check_update_post_response( $response ); 2860 2860 $new_data = $response->get_data(); 2861 $this->assert Equals( $new_data['date_gmt'], $new_data['date'] );2861 $this->assertSame( $new_data['date_gmt'], $new_data['date'] ); 2862 2862 $this->assertNotEquals( $new_data['date_gmt'], $future_date ); 2863 2863 2864 2864 $post = get_post( $post_id, 'ARRAY_A' ); 2865 $this->assert Equals( $post['post_date_gmt'], '0000-00-00 00:00:00' );2865 $this->assertSame( $post['post_date_gmt'], '0000-00-00 00:00:00' ); 2866 2866 $this->assertNotEquals( $new_data['date_gmt'], $future_date ); 2867 2867 $this->assertNotEquals( $new_data['date'], $future_date ); … … 2879 2879 $this->check_update_post_response( $response ); 2880 2880 $new_data = $response->get_data(); 2881 $this->assert Equals( self::$post_id, $new_data['id'] );2882 $this->assert Equals( $params['title']['raw'], $new_data['title']['raw'] );2883 $this->assert Equals( $params['content']['raw'], $new_data['content']['raw'] );2884 $this->assert Equals( $params['excerpt']['raw'], $new_data['excerpt']['raw'] );2881 $this->assertSame( self::$post_id, $new_data['id'] ); 2882 $this->assertSame( $params['title']['raw'], $new_data['title']['raw'] ); 2883 $this->assertSame( $params['content']['raw'], $new_data['content']['raw'] ); 2884 $this->assertSame( $params['excerpt']['raw'], $new_data['excerpt']['raw'] ); 2885 2885 $post = get_post( self::$post_id ); 2886 $this->assert Equals( $params['title']['raw'], $post->post_title );2887 $this->assert Equals( $params['content']['raw'], $post->post_content );2888 $this->assert Equals( $params['excerpt']['raw'], $post->post_excerpt );2886 $this->assertSame( $params['title']['raw'], $post->post_title ); 2887 $this->assertSame( $params['content']['raw'], $post->post_content ); 2888 $this->assertSame( $params['excerpt']['raw'], $post->post_excerpt ); 2889 2889 } 2890 2890 … … 2969 2969 $data = $response->get_data(); 2970 2970 $new_post = get_post( $data['id'] ); 2971 $this->assert Equals( 'gallery', $data['format'] );2972 $this->assert Equals( 'gallery', get_post_format( $new_post->ID ) );2971 $this->assertSame( 'gallery', $data['format'] ); 2972 $this->assertSame( 'gallery', get_post_format( $new_post->ID ) ); 2973 2973 } 2974 2974 … … 2987 2987 $data = $response->get_data(); 2988 2988 $new_post = get_post( $data['id'] ); 2989 $this->assert Equals( 'standard', $data['format'] );2989 $this->assertSame( 'standard', $data['format'] ); 2990 2990 $this->assertFalse( get_post_format( $new_post->ID ) ); 2991 2991 } … … 3022 3022 $request->set_body_params( $params ); 3023 3023 $response = rest_get_server()->dispatch( $request ); 3024 $this->assert Equals( 200, $response->get_status() );3024 $this->assertSame( 200, $response->get_status() ); 3025 3025 3026 3026 $data = $response->get_data(); 3027 $this->assert Equals( 'link', $data['format'] );3027 $this->assertSame( 'link', $data['format'] ); 3028 3028 } 3029 3029 … … 3048 3048 $new_post = get_post( $data['id'] ); 3049 3049 3050 $this->assert Equals( $new_content, $data['content']['raw'] );3051 $this->assert Equals( $new_content, $new_post->post_content );3050 $this->assertSame( $new_content, $data['content']['raw'] ); 3051 $this->assertSame( $new_content, $new_post->post_content ); 3052 3052 3053 3053 // The modified date should equal the current time. 3054 $this->assert Equals( gmdate( 'Y-m-d', strtotime( mysql_to_rfc3339( $expected_modified ) ) ), gmdate( 'Y-m-d', strtotime( $data['modified'] ) ) );3055 $this->assert Equals( gmdate( 'Y-m-d', strtotime( $expected_modified ) ), gmdate( 'Y-m-d', strtotime( $new_post->post_modified ) ) );3054 $this->assertSame( gmdate( 'Y-m-d', strtotime( mysql_to_rfc3339( $expected_modified ) ) ), gmdate( 'Y-m-d', strtotime( $data['modified'] ) ) ); 3055 $this->assertSame( gmdate( 'Y-m-d', strtotime( $expected_modified ) ), gmdate( 'Y-m-d', strtotime( $new_post->post_modified ) ) ); 3056 3056 } 3057 3057 … … 3077 3077 update_option( 'timezone_string', '' ); 3078 3078 3079 $this->assert Equals( 200, $response->get_status() );3079 $this->assertSame( 200, $response->get_status() ); 3080 3080 $data = $response->get_data(); 3081 3081 $post = get_post( $data['id'] ); 3082 3082 3083 $this->assert Equals( $results['date'], $data['date'] );3083 $this->assertSame( $results['date'], $data['date'] ); 3084 3084 $post_date = str_replace( 'T', ' ', $results['date'] ); 3085 $this->assert Equals( $post_date, $post->post_date );3086 3087 $this->assert Equals( $results['date_gmt'], $data['date_gmt'] );3085 $this->assertSame( $post_date, $post->post_date ); 3086 3087 $this->assertSame( $results['date_gmt'], $data['date_gmt'] ); 3088 3088 $post_date_gmt = str_replace( 'T', ' ', $results['date_gmt'] ); 3089 $this->assert Equals( $post_date_gmt, $post->post_date_gmt );3089 $this->assertSame( $post_date_gmt, $post->post_date_gmt ); 3090 3090 } 3091 3091 … … 3145 3145 3146 3146 $post = get_post( $post_id ); 3147 $this->assert Equals( $post->post_date, '2016-02-23 12:00:00' );3148 $this->assert Equals( $post->post_date_gmt, '0000-00-00 00:00:00' );3147 $this->assertSame( $post->post_date, '2016-02-23 12:00:00' ); 3148 $this->assertSame( $post->post_date_gmt, '0000-00-00 00:00:00' ); 3149 3149 3150 3150 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $post_id ) ); 3151 3151 $response = rest_get_server()->dispatch( $request ); 3152 $this->assert Equals( 200, $response->get_status() );3152 $this->assertSame( 200, $response->get_status() ); 3153 3153 $data = $response->get_data(); 3154 3154 3155 $this->assert Equals( '2016-02-23T12:00:00', $data['date'] );3156 $this->assert Equals( '2016-02-23T18:00:00', $data['date_gmt'] );3155 $this->assertSame( '2016-02-23T12:00:00', $data['date'] ); 3156 $this->assertSame( '2016-02-23T18:00:00', $data['date_gmt'] ); 3157 3157 3158 3158 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $post_id ) ); 3159 3159 $request->set_param( 'date', '2016-02-23T13:00:00' ); 3160 3160 $response = rest_get_server()->dispatch( $request ); 3161 $this->assert Equals( 200, $response->get_status() );3161 $this->assertSame( 200, $response->get_status() ); 3162 3162 $data = $response->get_data(); 3163 3163 3164 $this->assert Equals( '2016-02-23T13:00:00', $data['date'] );3165 $this->assert Equals( '2016-02-23T19:00:00', $data['date_gmt'] );3164 $this->assertSame( '2016-02-23T13:00:00', $data['date'] ); 3165 $this->assertSame( '2016-02-23T19:00:00', $data['date_gmt'] ); 3166 3166 3167 3167 $post = get_post( $post_id ); 3168 $this->assert Equals( $post->post_date, '2016-02-23 13:00:00' );3169 $this->assert Equals( $post->post_date_gmt, '2016-02-23 19:00:00' );3168 $this->assertSame( $post->post_date, '2016-02-23 13:00:00' ); 3169 $this->assertSame( $post->post_date_gmt, '2016-02-23 19:00:00' ); 3170 3170 3171 3171 update_option( 'timezone_string', '' ); … … 3185 3185 3186 3186 $new_data = $response->get_data(); 3187 $this->assert Equals( 'sample-slug', $new_data['slug'] );3187 $this->assertSame( 'sample-slug', $new_data['slug'] ); 3188 3188 $post = get_post( $new_data['id'] ); 3189 $this->assert Equals( 'sample-slug', $post->post_name );3189 $this->assertSame( 'sample-slug', $post->post_name ); 3190 3190 } 3191 3191 … … 3203 3203 3204 3204 $new_data = $response->get_data(); 3205 $this->assert Equals( 'test-accented-charaecters', $new_data['slug'] );3205 $this->assertSame( 'test-accented-charaecters', $new_data['slug'] ); 3206 3206 $post = get_post( $new_data['id'] ); 3207 $this->assert Equals( 'test-accented-charaecters', $post->post_name );3207 $this->assertSame( 'test-accented-charaecters', $post->post_name ); 3208 3208 } 3209 3209 … … 3221 3221 3222 3222 $new_data = $response->get_data(); 3223 $this->assert Equals( true,$new_data['sticky'] );3223 $this->assertTrue( $new_data['sticky'] ); 3224 3224 $post = get_post( $new_data['id'] ); 3225 $this->assert Equals( true,is_sticky( $post->ID ) );3225 $this->assertTrue( is_sticky( $post->ID ) ); 3226 3226 3227 3227 // Updating another field shouldn't change sticky status. … … 3236 3236 3237 3237 $new_data = $response->get_data(); 3238 $this->assert Equals( true,$new_data['sticky'] );3238 $this->assertTrue( $new_data['sticky'] ); 3239 3239 $post = get_post( $new_data['id'] ); 3240 $this->assert Equals( true,is_sticky( $post->ID ) );3240 $this->assertTrue( is_sticky( $post->ID ) ); 3241 3241 } 3242 3242 … … 3253 3253 $response = rest_get_server()->dispatch( $request ); 3254 3254 $new_data = $response->get_data(); 3255 $this->assert Equals( 'An Excerpt', $new_data['excerpt']['raw'] );3255 $this->assertSame( 'An Excerpt', $new_data['excerpt']['raw'] ); 3256 3256 } 3257 3257 … … 3268 3268 $response = rest_get_server()->dispatch( $request ); 3269 3269 $new_data = $response->get_data(); 3270 $this->assert Equals( '', $new_data['excerpt']['raw'] );3270 $this->assertSame( '', $new_data['excerpt']['raw'] ); 3271 3271 } 3272 3272 … … 3283 3283 $response = rest_get_server()->dispatch( $request ); 3284 3284 $new_data = $response->get_data(); 3285 $this->assert Equals( 'Some Content', $new_data['content']['raw'] );3285 $this->assertSame( 'Some Content', $new_data['content']['raw'] ); 3286 3286 } 3287 3287 … … 3298 3298 $response = rest_get_server()->dispatch( $request ); 3299 3299 $new_data = $response->get_data(); 3300 $this->assert Equals( '', $new_data['content']['raw'] );3300 $this->assertSame( '', $new_data['content']['raw'] ); 3301 3301 } 3302 3302 … … 3320 3320 $response = rest_get_server()->dispatch( $request ); 3321 3321 $data = $response->get_data(); 3322 $this->assert Equals( '', $data['password'] );3322 $this->assertSame( '', $data['password'] ); 3323 3323 } 3324 3324 … … 3390 3390 $response = rest_get_server()->dispatch( $request ); 3391 3391 $new_data = $response->get_data(); 3392 $this->assert Equals( "Rob O'Rourke's Diary", $new_data['title']['raw'] );3392 $this->assertSame( "Rob O'Rourke's Diary", $new_data['title']['raw'] ); 3393 3393 } 3394 3394 … … 3410 3410 $response = rest_get_server()->dispatch( $request ); 3411 3411 $new_data = $response->get_data(); 3412 $this->assert Equals( array( $category['term_id'] ), $new_data['categories'] );3412 $this->assertSame( array( $category['term_id'] ), $new_data['categories'] ); 3413 3413 $categories_path = ''; 3414 3414 $links = $response->get_links(); … … 3427 3427 $data = $response->get_data(); 3428 3428 $this->assertCount( 1, $data ); 3429 $this->assert Equals( 'Test Category', $data[0]['name'] );3429 $this->assertSame( 'Test Category', $data[0]['name'] ); 3430 3430 } 3431 3431 … … 3446 3446 $response = rest_get_server()->dispatch( $request ); 3447 3447 $new_data = $response->get_data(); 3448 $this->assert Equals( array(), $new_data['categories'] );3448 $this->assertSame( array(), $new_data['categories'] ); 3449 3449 } 3450 3450 … … 3500 3500 $post_template = get_page_template_slug( get_post( $data['id'] ) ); 3501 3501 3502 $this->assert Equals( 'post-my-test-template.php', $data['template'] );3503 $this->assert Equals( 'post-my-test-template.php', $post_template );3502 $this->assertSame( 'post-my-test-template.php', $data['template'] ); 3503 $this->assertSame( 'post-my-test-template.php', $post_template ); 3504 3504 } 3505 3505 … … 3531 3531 $post_template = get_page_template_slug( get_post( $data['id'] ) ); 3532 3532 3533 $this->assert Equals( '', $data['template'] );3534 $this->assert Equals( '', $post_template );3533 $this->assertSame( '', $data['template'] ); 3534 $this->assertSame( '', $post_template ); 3535 3535 } 3536 3536 … … 3555 3555 $response = rest_get_server()->dispatch( $request ); 3556 3556 3557 $this->assert Equals( 200, $response->get_status() );3557 $this->assertSame( 200, $response->get_status() ); 3558 3558 3559 3559 $data = $response->get_data(); 3560 3560 $post_template = get_page_template_slug( get_post( $data['id'] ) ); 3561 3561 3562 $this->assert Equals( 'post-my-invalid-template.php', $post_template );3563 $this->assert Equals( 'post-my-invalid-template.php', $data['template'] );3562 $this->assertSame( 'post-my-invalid-template.php', $post_template ); 3563 $this->assertSame( 'post-my-invalid-template.php', $data['template'] ); 3564 3564 } 3565 3565 … … 3571 3571 } 3572 3572 $response = rest_get_server()->dispatch( $request ); 3573 $this->assert Equals( 201, $response->get_status() );3573 $this->assertSame( 201, $response->get_status() ); 3574 3574 $actual_output = $response->get_data(); 3575 3575 3576 3576 // Compare expected API output to actual API output. 3577 $this->assert Equals( $expected_output['title']['raw'], $actual_output['title']['raw'] );3578 $this->assert Equals( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) );3579 $this->assert Equals( $expected_output['content']['raw'], $actual_output['content']['raw'] );3580 $this->assert Equals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) );3581 $this->assert Equals( $expected_output['excerpt']['raw'], $actual_output['excerpt']['raw'] );3582 $this->assert Equals( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) );3577 $this->assertSame( $expected_output['title']['raw'], $actual_output['title']['raw'] ); 3578 $this->assertSame( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) ); 3579 $this->assertSame( $expected_output['content']['raw'], $actual_output['content']['raw'] ); 3580 $this->assertSame( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); 3581 $this->assertSame( $expected_output['excerpt']['raw'], $actual_output['excerpt']['raw'] ); 3582 $this->assertSame( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) ); 3583 3583 3584 3584 // Compare expected API output to WP internal values. 3585 3585 $post = get_post( $actual_output['id'] ); 3586 $this->assert Equals( $expected_output['title']['raw'], $post->post_title );3587 $this->assert Equals( $expected_output['content']['raw'], $post->post_content );3588 $this->assert Equals( $expected_output['excerpt']['raw'], $post->post_excerpt );3586 $this->assertSame( $expected_output['title']['raw'], $post->post_title ); 3587 $this->assertSame( $expected_output['content']['raw'], $post->post_content ); 3588 $this->assertSame( $expected_output['excerpt']['raw'], $post->post_excerpt ); 3589 3589 3590 3590 // Update the post. … … 3594 3594 } 3595 3595 $response = rest_get_server()->dispatch( $request ); 3596 $this->assert Equals( 200, $response->get_status() );3596 $this->assertSame( 200, $response->get_status() ); 3597 3597 $actual_output = $response->get_data(); 3598 3598 3599 3599 // Compare expected API output to actual API output. 3600 $this->assert Equals( $expected_output['title']['raw'], $actual_output['title']['raw'] );3601 $this->assert Equals( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) );3602 $this->assert Equals( $expected_output['content']['raw'], $actual_output['content']['raw'] );3603 $this->assert Equals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) );3604 $this->assert Equals( $expected_output['excerpt']['raw'], $actual_output['excerpt']['raw'] );3605 $this->assert Equals( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) );3600 $this->assertSame( $expected_output['title']['raw'], $actual_output['title']['raw'] ); 3601 $this->assertSame( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) ); 3602 $this->assertSame( $expected_output['content']['raw'], $actual_output['content']['raw'] ); 3603 $this->assertSame( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); 3604 $this->assertSame( $expected_output['excerpt']['raw'], $actual_output['excerpt']['raw'] ); 3605 $this->assertSame( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) ); 3606 3606 3607 3607 // Compare expected API output to WP internal values. 3608 3608 $post = get_post( $actual_output['id'] ); 3609 $this->assert Equals( $expected_output['title']['raw'], $post->post_title );3610 $this->assert Equals( $expected_output['content']['raw'], $post->post_content );3611 $this->assert Equals( $expected_output['excerpt']['raw'], $post->post_excerpt );3609 $this->assertSame( $expected_output['title']['raw'], $post->post_title ); 3610 $this->assertSame( $expected_output['content']['raw'], $post->post_content ); 3611 $this->assertSame( $expected_output['excerpt']['raw'], $post->post_excerpt ); 3612 3612 } 3613 3613 … … 3807 3807 $response = rest_get_server()->dispatch( $request ); 3808 3808 3809 $this->assert Equals( 200, $response->get_status() );3809 $this->assertSame( 200, $response->get_status() ); 3810 3810 $data = $response->get_data(); 3811 $this->assert Equals( 'Deleted post', $data['title']['raw'] );3812 $this->assert Equals( 'trash', $data['status'] );3811 $this->assertSame( 'Deleted post', $data['title']['raw'] ); 3812 $this->assertSame( 'trash', $data['status'] ); 3813 3813 } 3814 3814 … … 3822 3822 $response = rest_get_server()->dispatch( $request ); 3823 3823 3824 $this->assert Equals( 200, $response->get_status() );3824 $this->assertSame( 200, $response->get_status() ); 3825 3825 $data = $response->get_data(); 3826 3826 $this->assertTrue( $data['deleted'] ); … … 3835 3835 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d', $post_id ) ); 3836 3836 $response = rest_get_server()->dispatch( $request ); 3837 $this->assert Equals( 200, $response->get_status() );3837 $this->assertSame( 200, $response->get_status() ); 3838 3838 $response = rest_get_server()->dispatch( $request ); 3839 3839 $this->assertErrorResponse( 'rest_already_trashed', $response, 410 ); … … 3890 3890 $data = $response->get_data(); 3891 3891 $properties = $data['schema']['properties']; 3892 $this->assert Equals( 26, count( $properties ) );3892 $this->assertSame( 26, count( $properties ) ); 3893 3893 $this->assertArrayHasKey( 'author', $properties ); 3894 3894 $this->assertArrayHasKey( 'comment_status', $properties ); … … 3969 3969 ); 3970 3970 3971 $this->assert Equals( $expected_keys, $keys );3971 $this->assertSame( $expected_keys, $keys ); 3972 3972 } 3973 3973 … … 4010 4010 ); 4011 4011 4012 $this->assert Equals( $expected_keys, $keys );4012 $this->assertSame( $expected_keys, $keys ); 4013 4013 } 4014 4014 … … 4032 4032 ); 4033 4033 4034 $this->assert Equals( $expected_keys, $keys );4034 $this->assertSame( $expected_keys, $keys ); 4035 4035 } 4036 4036 … … 4041 4041 $list_posts_args = $data['routes']['/wp/v2/posts']['endpoints'][0]['args']; 4042 4042 $status_arg = $list_posts_args['status']; 4043 $this->assertEquals( 'array', $status_arg['type'] ); 4044 $this->assertEquals( 4045 array( 4046 'type' => 'string', 4043 $this->assertSame( 'array', $status_arg['type'] ); 4044 $this->assertSame( 4045 array( 4047 4046 'enum' => array( 4048 4047 'publish', … … 4060 4059 'any', 4061 4060 ), 4061 'type' => 'string', 4062 4062 ), 4063 4063 $status_arg['items'] … … 4089 4089 4090 4090 $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); 4091 $this->assert Equals( $schema, $data['schema']['properties']['my_custom_int'] );4091 $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); 4092 4092 4093 4093 wp_set_current_user( 1 ); … … 4572 4572 $response = rest_get_server()->dispatch( $request ); 4573 4573 $data = $response->get_data(); 4574 $this->assert Equals( 200, $response->get_status() );4574 $this->assertSame( 200, $response->get_status() ); 4575 4575 $this->assertArrayNotHasKey( 'permalink_template', $data ); 4576 4576 $this->assertArrayNotHasKey( 'generated_slug', $data ); … … 4596 4596 $response = rest_get_server()->dispatch( $request ); 4597 4597 $data = $response->get_data(); 4598 $this->assert Equals( 200, $response->get_status() );4599 $this->assert Equals( $expected_permalink_template, $data['permalink_template'] );4600 $this->assert Equals( 'permalink-template', $data['generated_slug'] );4598 $this->assertSame( 200, $response->get_status() ); 4599 $this->assertSame( $expected_permalink_template, $data['permalink_template'] ); 4600 $this->assertSame( 'permalink-template', $data['generated_slug'] ); 4601 4601 4602 4602 // Neither 'permalink_template' and 'generated_slug' are expected for context=view. … … 4605 4605 $response = rest_get_server()->dispatch( $request ); 4606 4606 $data = $response->get_data(); 4607 $this->assert Equals( 200, $response->get_status() );4607 $this->assertSame( 200, $response->get_status() ); 4608 4608 $this->assertArrayNotHasKey( 'permalink_template', $data ); 4609 4609 $this->assertArrayNotHasKey( 'generated_slug', $data ); … … 4626 4626 ); 4627 4627 4628 $this->assert Equals( '0000-00-00 00:00:00', $post->post_date_gmt );4628 $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); 4629 4629 4630 4630 $get = new WP_REST_Request( 'GET', "/wp/v2/posts/{$post->ID}" ); … … 4643 4643 $this->assertEquals( strtotime( $get_body['date_gmt'] ), strtotime( $body['date_gmt'] ), 'The dates should be equal', 2 ); 4644 4644 4645 $this->assert Equals( '0000-00-00 00:00:00', get_post( $post->ID )->post_date_gmt );4645 $this->assertSame( '0000-00-00 00:00:00', get_post( $post->ID )->post_date_gmt ); 4646 4646 } 4647 4647 … … 4662 4662 ); 4663 4663 4664 $this->assert Equals( '0000-00-00 00:00:00', $post->post_date_gmt );4664 $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); 4665 4665 4666 4666 $get = new WP_REST_Request( 'GET', "/wp/v2/posts/{$post->ID}" ); … … 4703 4703 ); 4704 4704 4705 $this->assert Equals( '0000-00-00 00:00:00', $post->post_date_gmt );4705 $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); 4706 4706 4707 4707 $get = new WP_REST_Request( 'GET', "/wp/v2/posts/{$post->ID}" ); … … 4860 4860 4861 4861 $this->assertArrayHasKey( 'new_prop', $properties ); 4862 $this->assert Equals( array( 'new_context' ), $properties['new_prop']['context'] );4862 $this->assertSame( array( 'new_context' ), $properties['new_prop']['context'] ); 4863 4863 } 4864 4864
Note: See TracChangeset
for help on using the changeset viewer.