- 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-comments-controller.php
r48231 r48937 173 173 $response = rest_get_server()->dispatch( $request ); 174 174 $data = $response->get_data(); 175 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );176 $this->assert Equals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );175 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 176 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 177 177 // Single. 178 178 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments/' . self::$approved_id ); 179 179 $response = rest_get_server()->dispatch( $request ); 180 180 $data = $response->get_data(); 181 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );182 $this->assert Equals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );181 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 182 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 183 183 } 184 184 … … 189 189 $keys = array_keys( $data['endpoints'][0]['args'] ); 190 190 sort( $keys ); 191 $this->assert Equals(191 $this->assertSame( 192 192 array( 193 193 'after', … … 221 221 222 222 $response = rest_get_server()->dispatch( $request ); 223 $this->assert Equals( 200, $response->get_status() );223 $this->assertSame( 200, $response->get_status() ); 224 224 225 225 $comments = $response->get_data(); … … 245 245 246 246 $response = rest_get_server()->dispatch( $request ); 247 $this->assert Equals( 200, $response->get_status() );247 $this->assertSame( 200, $response->get_status() ); 248 248 249 249 $collection_data = $response->get_data(); … … 268 268 269 269 $response = rest_get_server()->dispatch( $request ); 270 $this->assert Equals( 200, $response->get_status() );270 $this->assertSame( 200, $response->get_status() ); 271 271 272 272 $collection_data = $response->get_data(); … … 308 308 309 309 $response = rest_get_server()->dispatch( $request ); 310 $this->assert Equals( 200, $response->get_status() );310 $this->assertSame( 200, $response->get_status() ); 311 311 312 312 $collection_data = $response->get_data(); … … 327 327 328 328 $response = rest_get_server()->dispatch( $request ); 329 $this->assert Equals( 200, $response->get_status() );329 $this->assertSame( 200, $response->get_status() ); 330 330 331 331 $collection_data = $response->get_data(); … … 346 346 347 347 $response = rest_get_server()->dispatch( $request ); 348 $this->assert Equals( 200, $response->get_status() );348 $this->assertSame( 200, $response->get_status() ); 349 349 350 350 $collection_data = $response->get_data(); … … 365 365 366 366 $response = rest_get_server()->dispatch( $request ); 367 $this->assert Equals( 200, $response->get_status() );367 $this->assertSame( 200, $response->get_status() ); 368 368 369 369 $collection_data = $response->get_data(); … … 384 384 385 385 $response = rest_get_server()->dispatch( $request ); 386 $this->assert Equals( 200, $response->get_status() );386 $this->assertSame( 200, $response->get_status() ); 387 387 388 388 $collection_data = $response->get_data(); … … 405 405 406 406 $response = rest_get_server()->dispatch( $request ); 407 $this->assert Equals( 200, $response->get_status() );407 $this->assertSame( 200, $response->get_status() ); 408 408 409 409 $collection_data = $response->get_data(); … … 430 430 $request->set_param( 'post', 0 ); 431 431 $response = rest_get_server()->dispatch( $request ); 432 $this->assert Equals( 200, $response->get_status() );432 $this->assertSame( 200, $response->get_status() ); 433 433 $comments = $response->get_data(); 434 434 $this->assertCount( 2, $comments ); … … 450 450 $request->set_param( 'context', 'edit' ); 451 451 $response = rest_get_server()->dispatch( $request ); 452 $this->assert Equals( 200, $response->get_status() );452 $this->assertSame( 200, $response->get_status() ); 453 453 } 454 454 … … 465 465 466 466 $response = rest_get_server()->dispatch( $request ); 467 $this->assert Equals( 200, $response->get_status() );467 $this->assertSame( 200, $response->get_status() ); 468 468 469 469 $comments = $response->get_data(); … … 489 489 $response = rest_get_server()->dispatch( $request ); 490 490 $data = $response->get_data(); 491 $this->assert Equals( 2, count( $data ) );492 $this->assert Equals( $id1, $data[0]['id'] );491 $this->assertSame( 2, count( $data ) ); 492 $this->assertSame( $id1, $data[0]['id'] ); 493 493 494 494 // 'orderby' => 'include'. … … 496 496 $response = rest_get_server()->dispatch( $request ); 497 497 $data = $response->get_data(); 498 $this->assert Equals( 2, count( $data ) );499 $this->assert Equals( $id2, $data[0]['id'] );498 $this->assertSame( 2, count( $data ) ); 499 $this->assertSame( $id2, $data[0]['id'] ); 500 500 501 501 // Invalid 'orderby' should error. … … 582 582 $response = rest_get_server()->dispatch( $request ); 583 583 $data = $response->get_data(); 584 $this->assert Equals( $id, $data[0]['id'] );584 $this->assertSame( $id, $data[0]['id'] ); 585 585 586 586 // 'order' => 'asc'. … … 588 588 $response = rest_get_server()->dispatch( $request ); 589 589 $data = $response->get_data(); 590 $this->assert Equals( self::$approved_id, $data[0]['id'] );590 $this->assertSame( self::$approved_id, $data[0]['id'] ); 591 591 592 592 // 'order' => 'asc,id' should error. … … 627 627 $request->set_param( 'author', self::$author_id ); 628 628 $response = rest_get_server()->dispatch( $request ); 629 $this->assert Equals( 200, $response->get_status() );629 $this->assertSame( 200, $response->get_status() ); 630 630 $comments = $response->get_data(); 631 631 $this->assertCount( 1, $comments ); … … 634 634 $request->set_param( 'author', array( self::$author_id, self::$subscriber_id ) ); 635 635 $response = rest_get_server()->dispatch( $request ); 636 $this->assert Equals( 200, $response->get_status() );636 $this->assertSame( 200, $response->get_status() ); 637 637 $comments = $response->get_data(); 638 638 $this->assertCount( 2, $comments ); … … 679 679 $request->set_param( 'author_exclude', self::$author_id ); 680 680 $response = rest_get_server()->dispatch( $request ); 681 $this->assert Equals( 200, $response->get_status() );681 $this->assertSame( 200, $response->get_status() ); 682 682 $comments = $response->get_data(); 683 683 $this->assertCount( $total_comments - 1, $comments ); … … 688 688 $request->set_param( 'author_exclude', array( self::$author_id, self::$subscriber_id ) ); 689 689 $response = rest_get_server()->dispatch( $request ); 690 $this->assert Equals( 200, $response->get_status() );690 $this->assertSame( 200, $response->get_status() ); 691 691 $comments = $response->get_data(); 692 692 $this->assertCount( $total_comments - 2, $comments ); … … 801 801 $data = $response->get_data(); 802 802 $this->assertCount( 1, $data ); 803 $this->assert Equals( $id, $data[0]['id'] );803 $this->assertSame( $id, $data[0]['id'] ); 804 804 } 805 805 … … 814 814 $response = rest_get_server()->dispatch( $request ); 815 815 $headers = $response->get_headers(); 816 $this->assert Equals( $total_comments, $headers['X-WP-Total'] );817 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );816 $this->assertSame( $total_comments, $headers['X-WP-Total'] ); 817 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 818 818 $next_link = add_query_arg( 819 819 array( … … 837 837 $response = rest_get_server()->dispatch( $request ); 838 838 $headers = $response->get_headers(); 839 $this->assert Equals( $total_comments, $headers['X-WP-Total'] );840 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );839 $this->assertSame( $total_comments, $headers['X-WP-Total'] ); 840 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 841 841 $prev_link = add_query_arg( 842 842 array( … … 859 859 $response = rest_get_server()->dispatch( $request ); 860 860 $headers = $response->get_headers(); 861 $this->assert Equals( $total_comments, $headers['X-WP-Total'] );862 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );861 $this->assertSame( $total_comments, $headers['X-WP-Total'] ); 862 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 863 863 $prev_link = add_query_arg( 864 864 array( … … 875 875 $response = rest_get_server()->dispatch( $request ); 876 876 $headers = $response->get_headers(); 877 $this->assert Equals( $total_comments, $headers['X-WP-Total'] );877 $this->assertSame( $total_comments, $headers['X-WP-Total'] ); 878 878 $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); 879 879 $prev_link = add_query_arg( … … 921 921 $data = $response->get_data(); 922 922 $this->assertCount( 1, $data ); 923 $this->assert Equals( $comment2, $data[0]['id'] );923 $this->assertSame( $comment2, $data[0]['id'] ); 924 924 } 925 925 … … 928 928 929 929 $response = rest_get_server()->dispatch( $request ); 930 $this->assert Equals( 200, $response->get_status() );930 $this->assertSame( 200, $response->get_status() ); 931 931 932 932 $data = $response->get_data(); … … 945 945 946 946 $response = rest_get_server()->dispatch( $request ); 947 $this->assert Equals( 200, $response->get_status() );947 $this->assertSame( 200, $response->get_status() ); 948 948 949 949 $data = $response->get_data(); … … 960 960 $obj = get_comment( self::$approved_id ); 961 961 $response = $endpoint->prepare_item_for_response( $obj, $request ); 962 $this->assert Equals(962 $this->assertSame( 963 963 array( 964 964 'id', … … 982 982 // Ignore the subdomain, since get_avatar_url() randomly sets 983 983 // the Gravatar server when building the URL string. 984 $this->assert Equals( substr( get_avatar_url( $comment->comment_author_email ), 9 ), substr( $data['author_avatar_urls'][96], 9 ) );984 $this->assertSame( substr( get_avatar_url( $comment->comment_author_email ), 9 ), substr( $data['author_avatar_urls'][96], 9 ) ); 985 985 } 986 986 … … 1044 1044 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$hold_id ) ); 1045 1045 $response = rest_get_server()->dispatch( $request ); 1046 $this->assert Equals( 200, $response->get_status() );1046 $this->assertSame( 200, $response->get_status() ); 1047 1047 } 1048 1048 … … 1067 1067 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 1068 1068 $response = rest_get_server()->dispatch( $request ); 1069 $this->assert Equals( 200, $response->get_status() );1069 $this->assertSame( 200, $response->get_status() ); 1070 1070 $this->assertArrayHasKey( 'children', $response->get_links() ); 1071 1071 } … … 1082 1082 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 1083 1083 $response = rest_get_server()->dispatch( $request ); 1084 $this->assert Equals( 200, $response->get_status() );1084 $this->assertSame( 200, $response->get_status() ); 1085 1085 $this->assertArrayNotHasKey( 'children', $response->get_links() ); 1086 1086 } … … 1118 1118 1119 1119 $response = rest_get_server()->dispatch( $request ); 1120 $this->assert Equals( 200, $response->get_status() );1120 $this->assertSame( 200, $response->get_status() ); 1121 1121 } 1122 1122 … … 1138 1138 1139 1139 $response = rest_get_server()->dispatch( $request ); 1140 $this->assert Equals( 201, $response->get_status() );1140 $this->assertSame( 201, $response->get_status() ); 1141 1141 1142 1142 $data = $response->get_data(); 1143 1143 $this->check_comment_data( $data, 'edit', $response->get_links() ); 1144 $this->assert Equals( 'hold', $data['status'] );1145 $this->assert Equals( '2014-11-07T10:14:25', $data['date'] );1146 $this->assert Equals( self::$post_id, $data['post'] );1144 $this->assertSame( 'hold', $data['status'] ); 1145 $this->assertSame( '2014-11-07T10:14:25', $data['date'] ); 1146 $this->assertSame( self::$post_id, $data['post'] ); 1147 1147 } 1148 1148 … … 1213 1213 update_option( 'timezone_string', '' ); 1214 1214 1215 $this->assert Equals( 201, $response->get_status() );1215 $this->assertSame( 201, $response->get_status() ); 1216 1216 $data = $response->get_data(); 1217 1217 $comment = get_comment( $data['id'] ); 1218 1218 1219 $this->assert Equals( $results['date'], $data['date'] );1219 $this->assertSame( $results['date'], $data['date'] ); 1220 1220 $comment_date = str_replace( 'T', ' ', $results['date'] ); 1221 $this->assert Equals( $comment_date, $comment->comment_date );1222 1223 $this->assert Equals( $results['date_gmt'], $data['date_gmt'] );1221 $this->assertSame( $comment_date, $comment->comment_date ); 1222 1223 $this->assertSame( $results['date_gmt'], $data['date_gmt'] ); 1224 1224 $comment_date_gmt = str_replace( 'T', ' ', $results['date_gmt'] ); 1225 $this->assert Equals( $comment_date_gmt, $comment->comment_date_gmt );1225 $this->assertSame( $comment_date_gmt, $comment->comment_date_gmt ); 1226 1226 } 1227 1227 … … 1244 1244 1245 1245 $response = rest_get_server()->dispatch( $request ); 1246 $this->assert Equals( 201, $response->get_status() );1246 $this->assertSame( 201, $response->get_status() ); 1247 1247 1248 1248 $data = $response->get_data(); 1249 1249 $new_comment = get_comment( $data['id'] ); 1250 $this->assert Equals( $params['content']['raw'], $new_comment->comment_content );1250 $this->assertSame( $params['content']['raw'], $new_comment->comment_content ); 1251 1251 } 1252 1252 … … 1444 1444 $request->set_body( wp_json_encode( $params ) ); 1445 1445 $response = rest_get_server()->dispatch( $request ); 1446 $this->assert Equals( 201, $response->get_status() );1446 $this->assertSame( 201, $response->get_status() ); 1447 1447 1448 1448 $data = $response->get_data(); 1449 $this->assert Equals( $subscriber_id, $data['author'] );1450 $this->assert Equals( '127.0.0.1', $data['author_ip'] );1449 $this->assertSame( $subscriber_id, $data['author'] ); 1450 $this->assertSame( '127.0.0.1', $data['author_ip'] ); 1451 1451 } 1452 1452 … … 1471 1471 1472 1472 $response = rest_get_server()->dispatch( $request ); 1473 $this->assert Equals( 201, $response->get_status() );1473 $this->assertSame( 201, $response->get_status() ); 1474 1474 1475 1475 $data = $response->get_data(); 1476 $this->assert Equals( 'comment', $data['type'] );1476 $this->assertSame( 'comment', $data['type'] ); 1477 1477 1478 1478 $comment_id = $data['id']; … … 1483 1483 $collection_response = rest_get_server()->dispatch( $collection ); 1484 1484 $collection_data = $collection_response->get_data(); 1485 $this->assert Equals( $comment_id, $collection_data[0]['id'] );1485 $this->assertSame( $comment_id, $collection_data[0]['id'] ); 1486 1486 } 1487 1487 … … 1560 1560 $response = rest_get_server()->dispatch( $request ); 1561 1561 1562 $this->assert Equals( 201, $response->get_status() );1562 $this->assertSame( 201, $response->get_status() ); 1563 1563 $data = $response->get_data(); 1564 $this->assert Equals( $user_id, $data['author'] );1564 $this->assertSame( $user_id, $data['author'] ); 1565 1565 1566 1566 // Check author data matches. 1567 1567 $author = get_user_by( 'id', $user_id ); 1568 1568 $comment = get_comment( $data['id'] ); 1569 $this->assert Equals( $author->display_name, $comment->comment_author );1570 $this->assert Equals( $author->user_email, $comment->comment_author_email );1571 $this->assert Equals( $author->user_url, $comment->comment_author_url );1569 $this->assertSame( $author->display_name, $comment->comment_author ); 1570 $this->assertSame( $author->user_email, $comment->comment_author_email ); 1571 $this->assertSame( $author->user_url, $comment->comment_author_url ); 1572 1572 } 1573 1573 … … 1589 1589 $response = rest_get_server()->dispatch( $request ); 1590 1590 1591 $this->assert Equals( 201, $response->get_status() );1591 $this->assertSame( 201, $response->get_status() ); 1592 1592 $data = $response->get_data(); 1593 $this->assert Equals( self::$subscriber_id, $data['author'] );1594 $this->assert Equals( 'Homer Jay Simpson', $data['author_name'] );1595 $this->assert Equals( 'chunkylover53@aol.com', $data['author_email'] );1596 $this->assert Equals( 'http://compuglobalhypermeganet.com', $data['author_url'] );1593 $this->assertSame( self::$subscriber_id, $data['author'] ); 1594 $this->assertSame( 'Homer Jay Simpson', $data['author_name'] ); 1595 $this->assertSame( 'chunkylover53@aol.com', $data['author_email'] ); 1596 $this->assertSame( 'http://compuglobalhypermeganet.com', $data['author_url'] ); 1597 1597 } 1598 1598 … … 1679 1679 1680 1680 $response = rest_get_server()->dispatch( $request ); 1681 $this->assert Equals( 201, $response->get_status() );1681 $this->assertSame( 201, $response->get_status() ); 1682 1682 1683 1683 $data = $response->get_data(); 1684 $this->assert Equals( 'approved', $data['status'] );1685 $this->assert Equals( '139.130.4.5', $data['author_ip'] );1686 $this->assert Equals( 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36', $data['author_user_agent'] );1684 $this->assertSame( 'approved', $data['status'] ); 1685 $this->assertSame( '139.130.4.5', $data['author_ip'] ); 1686 $this->assertSame( 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36', $data['author_user_agent'] ); 1687 1687 } 1688 1688 … … 1704 1704 1705 1705 $response = rest_get_server()->dispatch( $request ); 1706 $this->assert Equals( 201, $response->get_status() );1706 $this->assertSame( 201, $response->get_status() ); 1707 1707 1708 1708 $data = $response->get_data(); 1709 1709 1710 1710 $new_comment = get_comment( $data['id'] ); 1711 $this->assert Equals( 'Mozilla/4.0 (compatible; MSIE 5.5; AOL 4.0; Windows 95)', $new_comment->comment_agent );1711 $this->assertSame( 'Mozilla/4.0 (compatible; MSIE 5.5; AOL 4.0; Windows 95)', $new_comment->comment_agent ); 1712 1712 } 1713 1713 … … 1730 1730 $data = $response->get_data(); 1731 1731 $new_comment = get_comment( $data['id'] ); 1732 $this->assert Equals( '127.0.0.3', $new_comment->comment_author_IP );1732 $this->assertSame( '127.0.0.3', $new_comment->comment_author_IP ); 1733 1733 } 1734 1734 … … 1791 1791 $data = $response->get_data(); 1792 1792 $new_comment = get_comment( $data['id'] ); 1793 $this->assert Equals( '127.0.0.2', $new_comment->comment_author_IP );1793 $this->assertSame( '127.0.0.2', $new_comment->comment_author_IP ); 1794 1794 } 1795 1795 … … 1958 1958 $response = rest_get_server()->dispatch( $request ); 1959 1959 1960 $this->assert Equals( 409, $response->get_status() );1960 $this->assertSame( 409, $response->get_status() ); 1961 1961 } 1962 1962 … … 1979 1979 $response = rest_get_server()->dispatch( $request ); 1980 1980 1981 $this->assert Equals( 403, $response->get_status() );1981 $this->assertSame( 403, $response->get_status() ); 1982 1982 } 1983 1983 … … 1991 1991 $request->set_param( 'post', self::$post_id ); 1992 1992 $response = rest_get_server()->dispatch( $request ); 1993 $this->assert Equals( 401, $response->get_status() );1993 $this->assertSame( 401, $response->get_status() ); 1994 1994 $data = $response->get_data(); 1995 $this->assert Equals( 'rest_comment_login_required', $data['code'] );1995 $this->assertSame( 'rest_comment_login_required', $data['code'] ); 1996 1996 } 1997 1997 … … 2052 2052 2053 2053 $response = rest_get_server()->dispatch( $request ); 2054 $this->assert Equals( 201, $response->get_status() );2054 $this->assertSame( 201, $response->get_status() ); 2055 2055 2056 2056 $params = array( … … 2067 2067 2068 2068 $response = rest_get_server()->dispatch( $request ); 2069 $this->assert Equals( 400, $response->get_status() );2069 $this->assertSame( 400, $response->get_status() ); 2070 2070 } 2071 2071 … … 2230 2230 $request->set_body( wp_json_encode( $params ) ); 2231 2231 $response = rest_get_server()->dispatch( $request ); 2232 $this->assert Equals( 201, $response->get_status() );2232 $this->assertSame( 201, $response->get_status() ); 2233 2233 } 2234 2234 … … 2254 2254 2255 2255 $response = rest_get_server()->dispatch( $request ); 2256 $this->assert Equals( 200, $response->get_status() );2256 $this->assertSame( 200, $response->get_status() ); 2257 2257 2258 2258 $comment = $response->get_data(); 2259 2259 $updated = get_comment( self::$approved_id ); 2260 $this->assert Equals( $params['content'], $comment['content']['raw'] );2261 $this->assert Equals( $params['author'], $comment['author'] );2262 $this->assert Equals( $params['author_name'], $comment['author_name'] );2263 $this->assert Equals( $params['author_url'], $comment['author_url'] );2264 $this->assert Equals( $params['author_email'], $comment['author_email'] );2265 $this->assert Equals( $params['author_ip'], $comment['author_ip'] );2266 $this->assert Equals( $params['post'], $comment['post'] );2267 2268 $this->assert Equals( mysql_to_rfc3339( $updated->comment_date ), $comment['date'] );2269 $this->assert Equals( '2014-11-07T10:14:25', $comment['date'] );2260 $this->assertSame( $params['content'], $comment['content']['raw'] ); 2261 $this->assertSame( $params['author'], $comment['author'] ); 2262 $this->assertSame( $params['author_name'], $comment['author_name'] ); 2263 $this->assertSame( $params['author_url'], $comment['author_url'] ); 2264 $this->assertSame( $params['author_email'], $comment['author_email'] ); 2265 $this->assertSame( $params['author_ip'], $comment['author_ip'] ); 2266 $this->assertSame( $params['post'], $comment['post'] ); 2267 2268 $this->assertSame( mysql_to_rfc3339( $updated->comment_date ), $comment['date'] ); 2269 $this->assertSame( '2014-11-07T10:14:25', $comment['date'] ); 2270 2270 } 2271 2271 … … 2291 2291 update_option( 'timezone_string', '' ); 2292 2292 2293 $this->assert Equals( 200, $response->get_status() );2293 $this->assertSame( 200, $response->get_status() ); 2294 2294 $data = $response->get_data(); 2295 2295 $comment = get_comment( $data['id'] ); 2296 2296 2297 $this->assert Equals( $results['date'], $data['date'] );2297 $this->assertSame( $results['date'], $data['date'] ); 2298 2298 $comment_date = str_replace( 'T', ' ', $results['date'] ); 2299 $this->assert Equals( $comment_date, $comment->comment_date );2300 2301 $this->assert Equals( $results['date_gmt'], $data['date_gmt'] );2299 $this->assertSame( $comment_date, $comment->comment_date ); 2300 2301 $this->assertSame( $results['date_gmt'], $data['date_gmt'] ); 2302 2302 $comment_date_gmt = str_replace( 'T', ' ', $results['date_gmt'] ); 2303 $this->assert Equals( $comment_date_gmt, $comment->comment_date_gmt );2303 $this->assertSame( $comment_date_gmt, $comment->comment_date_gmt ); 2304 2304 } 2305 2305 … … 2314 2314 // Sending a request without content is fine. 2315 2315 $response = rest_get_server()->dispatch( $request ); 2316 $this->assert Equals( 200, $response->get_status() );2316 $this->assertSame( 200, $response->get_status() ); 2317 2317 2318 2318 // Sending a request with empty comment is not fine. … … 2334 2334 // even if no DB rows are updated. 2335 2335 $response = rest_get_server()->dispatch( $request ); 2336 $this->assert Equals( 200, $response->get_status() );2337 2338 $response = rest_get_server()->dispatch( $request ); 2339 $this->assert Equals( 200, $response->get_status() );2336 $this->assertSame( 200, $response->get_status() ); 2337 2338 $response = rest_get_server()->dispatch( $request ); 2339 $this->assertSame( 200, $response->get_status() ); 2340 2340 } 2341 2341 … … 2359 2359 2360 2360 $response = rest_get_server()->dispatch( $request ); 2361 $this->assert Equals( 200, $response->get_status() );2361 $this->assertSame( 200, $response->get_status() ); 2362 2362 2363 2363 $comment = $response->get_data(); 2364 2364 $updated = get_comment( $comment_id ); 2365 $this->assert Equals( 'approved', $comment['status'] );2365 $this->assertSame( 'approved', $comment['status'] ); 2366 2366 $this->assertEquals( 1, $updated->comment_approved ); 2367 2367 } … … 2387 2387 2388 2388 $response = rest_get_server()->dispatch( $request ); 2389 $this->assert Equals( 200, $response->get_status() );2389 $this->assertSame( 200, $response->get_status() ); 2390 2390 2391 2391 $comment = $response->get_data(); 2392 2392 $updated = get_comment( $comment_id ); 2393 $this->assert Equals( 'approved', $comment['status'] );2393 $this->assertSame( 'approved', $comment['status'] ); 2394 2394 $this->assertEquals( 1, $updated->comment_approved ); 2395 $this->assert Equals( 'some content', $updated->comment_content );2395 $this->assertSame( 'some content', $updated->comment_content ); 2396 2396 } 2397 2397 … … 2409 2409 2410 2410 $response = rest_get_server()->dispatch( $request ); 2411 $this->assert Equals( 200, $response->get_status() );2411 $this->assertSame( 200, $response->get_status() ); 2412 2412 2413 2413 $comment = $response->get_data(); 2414 2414 $updated = get_comment( self::$approved_id ); 2415 $this->assert Equals( $params['date_gmt'], $comment['date_gmt'] );2416 $this->assert Equals( $params['date_gmt'], mysql_to_rfc3339( $updated->comment_date_gmt ) );2415 $this->assertSame( $params['date_gmt'], $comment['date_gmt'] ); 2416 $this->assertSame( $params['date_gmt'], mysql_to_rfc3339( $updated->comment_date_gmt ) ); 2417 2417 } 2418 2418 … … 2433 2433 2434 2434 $response = rest_get_server()->dispatch( $request ); 2435 $this->assert Equals( 200, $response->get_status() );2435 $this->assertSame( 200, $response->get_status() ); 2436 2436 } 2437 2437 … … 2453 2453 2454 2454 $response = rest_get_server()->dispatch( $request ); 2455 $this->assert Equals( 200, $response->get_status() );2455 $this->assertSame( 200, $response->get_status() ); 2456 2456 } 2457 2457 … … 2472 2472 2473 2473 $response = rest_get_server()->dispatch( $request ); 2474 $this->assert Equals( 200, $response->get_status() );2474 $this->assertSame( 200, $response->get_status() ); 2475 2475 } 2476 2476 … … 2492 2492 2493 2493 $response = rest_get_server()->dispatch( $request ); 2494 $this->assert Equals( 200, $response->get_status() );2494 $this->assertSame( 200, $response->get_status() ); 2495 2495 } 2496 2496 … … 2545 2545 $response = rest_get_server()->dispatch( $request ); 2546 2546 2547 $this->assert Equals( 200, $response->get_status() );2547 $this->assertSame( 200, $response->get_status() ); 2548 2548 2549 2549 $comment = $response->get_data(); 2550 2550 $updated = get_comment( self::$approved_id ); 2551 $this->assert Equals( $params['content']['raw'], $updated->comment_content );2551 $this->assertSame( $params['content']['raw'], $updated->comment_content ); 2552 2552 } 2553 2553 … … 2640 2640 2641 2641 $response = rest_get_server()->dispatch( $request ); 2642 $this->assert Equals( 200, $response->get_status() );2642 $this->assertSame( 200, $response->get_status() ); 2643 2643 2644 2644 $comment = $response->get_data(); 2645 2645 $updated = get_comment( self::$approved_id ); 2646 2646 2647 $this->assert Equals( $params['content'], $updated->comment_content );2648 $this->assert Equals( self::$post_id, $comment['post'] );2649 $this->assert Equals( '2019-10-07T23:14:25', $comment['date'] );2647 $this->assertSame( $params['content'], $updated->comment_content ); 2648 $this->assertSame( self::$post_id, $comment['post'] ); 2649 $this->assertSame( '2019-10-07T23:14:25', $comment['date'] ); 2650 2650 } 2651 2651 … … 2695 2695 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 2696 2696 $response = rest_get_server()->dispatch( $request ); 2697 $this->assert Equals( 200, $response->get_status() );2697 $this->assertSame( 200, $response->get_status() ); 2698 2698 $this->assertArrayNotHasKey( 'children', $response->get_links() ); 2699 2699 … … 2703 2703 $request->set_param( 'content', rand_str() ); 2704 2704 $response = rest_get_server()->dispatch( $request ); 2705 $this->assert Equals( 200, $response->get_status() );2705 $this->assertSame( 200, $response->get_status() ); 2706 2706 2707 2707 // Check if comment 1 now has the child link. 2708 2708 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 2709 2709 $response = rest_get_server()->dispatch( $request ); 2710 $this->assert Equals( 200, $response->get_status() );2710 $this->assertSame( 200, $response->get_status() ); 2711 2711 $this->assertArrayHasKey( 'children', $response->get_links() ); 2712 2712 } … … 2830 2830 } 2831 2831 $response = rest_get_server()->dispatch( $request ); 2832 $this->assert Equals( 201, $response->get_status() );2832 $this->assertSame( 201, $response->get_status() ); 2833 2833 $actual_output = $response->get_data(); 2834 2834 … … 2836 2836 $this->assertInternalType( 'array', $actual_output['content'] ); 2837 2837 $this->assertArrayHasKey( 'raw', $actual_output['content'] ); 2838 $this->assert Equals( $expected_output['content']['raw'], $actual_output['content']['raw'] );2839 $this->assert Equals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) );2840 $this->assert Equals( $expected_output['author_name'], $actual_output['author_name'] );2841 $this->assert Equals( $expected_output['author_user_agent'], $actual_output['author_user_agent'] );2838 $this->assertSame( $expected_output['content']['raw'], $actual_output['content']['raw'] ); 2839 $this->assertSame( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); 2840 $this->assertSame( $expected_output['author_name'], $actual_output['author_name'] ); 2841 $this->assertSame( $expected_output['author_user_agent'], $actual_output['author_user_agent'] ); 2842 2842 2843 2843 // Compare expected API output to WP internal values. 2844 2844 $comment = get_comment( $actual_output['id'] ); 2845 $this->assert Equals( $expected_output['content']['raw'], $comment->comment_content );2846 $this->assert Equals( $expected_output['author_name'], $comment->comment_author );2847 $this->assert Equals( $expected_output['author_user_agent'], $comment->comment_agent );2845 $this->assertSame( $expected_output['content']['raw'], $comment->comment_content ); 2846 $this->assertSame( $expected_output['author_name'], $comment->comment_author ); 2847 $this->assertSame( $expected_output['author_user_agent'], $comment->comment_agent ); 2848 2848 2849 2849 // Update the comment. … … 2856 2856 $request->set_param( 'author_ip', '127.0.0.2' ); 2857 2857 $response = rest_get_server()->dispatch( $request ); 2858 $this->assert Equals( 200, $response->get_status() );2858 $this->assertSame( 200, $response->get_status() ); 2859 2859 $actual_output = $response->get_data(); 2860 2860 2861 2861 // Compare expected API output to actual API output. 2862 $this->assert Equals( $expected_output['content']['raw'], $actual_output['content']['raw'] );2863 $this->assert Equals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) );2864 $this->assert Equals( $expected_output['author_name'], $actual_output['author_name'] );2865 $this->assert Equals( $expected_output['author_user_agent'], $actual_output['author_user_agent'] );2862 $this->assertSame( $expected_output['content']['raw'], $actual_output['content']['raw'] ); 2863 $this->assertSame( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); 2864 $this->assertSame( $expected_output['author_name'], $actual_output['author_name'] ); 2865 $this->assertSame( $expected_output['author_user_agent'], $actual_output['author_user_agent'] ); 2866 2866 2867 2867 // Compare expected API output to WP internal values. 2868 2868 $comment = get_comment( $actual_output['id'] ); 2869 $this->assert Equals( $expected_output['content']['raw'], $comment->comment_content );2870 $this->assert Equals( $expected_output['author_name'], $comment->comment_author );2871 $this->assert Equals( $expected_output['author_user_agent'], $comment->comment_agent );2869 $this->assertSame( $expected_output['content']['raw'], $comment->comment_content ); 2870 $this->assertSame( $expected_output['author_name'], $comment->comment_author ); 2871 $this->assertSame( $expected_output['author_user_agent'], $comment->comment_agent ); 2872 2872 } 2873 2873 … … 2875 2875 wp_set_current_user( self::$editor_id ); 2876 2876 2877 $this->assert Equals( ! is_multisite(), current_user_can( 'unfiltered_html' ) );2877 $this->assertSame( ! is_multisite(), current_user_can( 'unfiltered_html' ) ); 2878 2878 $this->verify_comment_roundtrip( 2879 2879 array( … … 2989 2989 $request->set_param( 'force', 'false' ); 2990 2990 $response = rest_get_server()->dispatch( $request ); 2991 $this->assert Equals( 200, $response->get_status() );2991 $this->assertSame( 200, $response->get_status() ); 2992 2992 2993 2993 $data = $response->get_data(); 2994 $this->assert Equals( 'trash', $data['status'] );2994 $this->assertSame( 'trash', $data['status'] ); 2995 2995 } 2996 2996 … … 3010 3010 3011 3011 $response = rest_get_server()->dispatch( $request ); 3012 $this->assert Equals( 200, $response->get_status() );3012 $this->assertSame( 200, $response->get_status() ); 3013 3013 $data = $response->get_data(); 3014 3014 $this->assertTrue( $data['deleted'] ); … … 3029 3029 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) ); 3030 3030 $response = rest_get_server()->dispatch( $request ); 3031 $this->assert Equals( 200, $response->get_status() );3031 $this->assertSame( 200, $response->get_status() ); 3032 3032 $data = $response->get_data(); 3033 3033 $response = rest_get_server()->dispatch( $request ); … … 3073 3073 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%s', $child_comment ) ); 3074 3074 $response = rest_get_server()->dispatch( $request ); 3075 $this->assert Equals( 200, $response->get_status() );3075 $this->assertSame( 200, $response->get_status() ); 3076 3076 3077 3077 // Verify children link is gone. 3078 3078 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 3079 3079 $response = rest_get_server()->dispatch( $request ); 3080 $this->assert Equals( 200, $response->get_status() );3080 $this->assertSame( 200, $response->get_status() ); 3081 3081 $this->assertArrayNotHasKey( 'children', $response->get_links() ); 3082 3082 } … … 3087 3087 $data = $response->get_data(); 3088 3088 $properties = $data['schema']['properties']; 3089 $this->assert Equals( 17, count( $properties ) );3089 $this->assertSame( 17, count( $properties ) ); 3090 3090 $this->assertArrayHasKey( 'id', $properties ); 3091 3091 $this->assertArrayHasKey( 'author', $properties ); … … 3106 3106 $this->assertArrayHasKey( 'type', $properties ); 3107 3107 3108 $this->assert Equals( 0, $properties['parent']['default'] );3109 $this->assert Equals( 0, $properties['post']['default'] );3110 3111 $this->assert Equals( true,$properties['link']['readonly'] );3112 $this->assert Equals( true,$properties['type']['readonly'] );3108 $this->assertSame( 0, $properties['parent']['default'] ); 3109 $this->assertSame( 0, $properties['post']['default'] ); 3110 3111 $this->assertTrue( $properties['link']['readonly'] ); 3112 $this->assertTrue( $properties['type']['readonly'] ); 3113 3113 } 3114 3114 … … 3148 3148 3149 3149 $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); 3150 $this->assert Equals( $schema, $data['schema']['properties']['my_custom_int'] );3150 $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); 3151 3151 3152 3152 $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . self::$approved_id ); … … 3239 3239 $this->assertEquals( $comment->comment_parent, $data['parent'] ); 3240 3240 $this->assertEquals( $comment->user_id, $data['author'] ); 3241 $this->assert Equals( $comment->comment_author, $data['author_name'] );3242 $this->assert Equals( $comment->comment_author_url, $data['author_url'] );3243 $this->assert Equals( wpautop( $comment->comment_content ), $data['content']['rendered'] );3244 $this->assert Equals( mysql_to_rfc3339( $comment->comment_date ), $data['date'] );3245 $this->assert Equals( mysql_to_rfc3339( $comment->comment_date_gmt ), $data['date_gmt'] );3246 $this->assert Equals( get_comment_link( $comment ), $data['link'] );3241 $this->assertSame( $comment->comment_author, $data['author_name'] ); 3242 $this->assertSame( $comment->comment_author_url, $data['author_url'] ); 3243 $this->assertSame( wpautop( $comment->comment_content ), $data['content']['rendered'] ); 3244 $this->assertSame( mysql_to_rfc3339( $comment->comment_date ), $data['date'] ); 3245 $this->assertSame( mysql_to_rfc3339( $comment->comment_date_gmt ), $data['date_gmt'] ); 3246 $this->assertSame( get_comment_link( $comment ), $data['link'] ); 3247 3247 $this->assertContains( 'author_avatar_urls', $data ); 3248 3248 $this->assertEqualSets( … … 3256 3256 3257 3257 if ( 'edit' === $context ) { 3258 $this->assert Equals( $comment->comment_author_email, $data['author_email'] );3259 $this->assert Equals( $comment->comment_author_IP, $data['author_ip'] );3260 $this->assert Equals( $comment->comment_agent, $data['author_user_agent'] );3261 $this->assert Equals( $comment->comment_content, $data['content']['raw'] );3258 $this->assertSame( $comment->comment_author_email, $data['author_email'] ); 3259 $this->assertSame( $comment->comment_author_IP, $data['author_ip'] ); 3260 $this->assertSame( $comment->comment_agent, $data['author_user_agent'] ); 3261 $this->assertSame( $comment->comment_content, $data['content']['raw'] ); 3262 3262 } 3263 3263 … … 3294 3294 $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . $comment_id ); 3295 3295 $response = rest_get_server()->dispatch( $request ); 3296 $this->assert Equals( 403, $response->get_status() );3296 $this->assertSame( 403, $response->get_status() ); 3297 3297 } 3298 3298 }
Note: See TracChangeset
for help on using the changeset viewer.