- Timestamp:
- 11/21/2016 05:31:07 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php
r39302 r39327 801 801 802 802 public function test_get_comment_not_approved_same_user() { 803 wp_set_current_user( self::$ subscriber_id );803 wp_set_current_user( self::$admin_id ); 804 804 805 805 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$hold_id ) ); … … 843 843 844 844 public function test_get_comment_with_password_without_edit_post_permission() { 845 wp_set_current_user( 0);845 wp_set_current_user( self::$subscriber_id ); 846 846 $args = array( 847 847 'comment_approved' => 1, … … 851 851 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $password_comment ) ); 852 852 $response = $this->server->dispatch( $request ); 853 $this->assertErrorResponse( 'rest_cannot_read', $response, 40 1);853 $this->assertErrorResponse( 'rest_cannot_read', $response, 403 ); 854 854 } 855 855 856 856 public function test_create_item() { 857 wp_set_current_user( 0);857 wp_set_current_user( self::$admin_id ); 858 858 859 859 $params = array( … … 874 874 875 875 $data = $response->get_data(); 876 $this->check_comment_data( $data, ' view', $response->get_links() );876 $this->check_comment_data( $data, 'edit', $response->get_links() ); 877 877 $this->assertEquals( 'hold', $data['status'] ); 878 878 $this->assertEquals( '2014-11-07T10:14:25', $data['date'] ); … … 881 881 882 882 public function test_create_item_using_accepted_content_raw_value() { 883 wp_set_current_user( 0);883 wp_set_current_user( self::$admin_id ); 884 884 885 885 $params = array( … … 906 906 907 907 public function test_create_comment_missing_required_author_name_and_email_per_option_value() { 908 add_filter( 'rest_allow_anonymous_comments', '__return_true' ); 908 909 update_option( 'require_name_email', 1 ); 909 910 … … 918 919 919 920 $response = $this->server->dispatch( $request ); 921 920 922 $this->assertErrorResponse( 'rest_comment_author_data_required', $response, 400 ); 921 923 … … 924 926 925 927 public function test_create_comment_missing_required_author_name_per_option_value() { 928 wp_set_current_user( self::$admin_id ); 926 929 update_option( 'require_name_email', 1 ); 927 930 … … 943 946 944 947 public function test_create_comment_missing_required_author_email_per_option_value() { 948 wp_set_current_user( self::$admin_id ); 945 949 update_option( 'require_name_email', 1 ); 946 950 … … 962 966 963 967 public function test_create_comment_author_email_too_short() { 964 wp_set_current_user( 0);968 wp_set_current_user( self::$admin_id ); 965 969 966 970 $params = array( … … 983 987 984 988 public function test_create_item_invalid_no_content() { 985 wp_set_current_user( 0);989 wp_set_current_user( self::$admin_id ); 986 990 987 991 $params = array( … … 1006 1010 1007 1011 public function test_create_item_invalid_date() { 1008 wp_set_current_user( 0);1012 wp_set_current_user( self::$admin_id ); 1009 1013 1010 1014 $params = array( … … 1350 1354 1351 1355 public function test_create_comment_author_ip_no_permission() { 1356 wp_set_current_user( self::$subscriber_id ); 1352 1357 $params = array( 1353 1358 'author_name' => 'Comic Book Guy', … … 1362 1367 $request->set_body( wp_json_encode( $params ) ); 1363 1368 $response = $this->server->dispatch( $request ); 1364 $this->assertErrorResponse( 'rest_comment_invalid_author_ip', $response, 40 1);1369 $this->assertErrorResponse( 'rest_comment_invalid_author_ip', $response, 403 ); 1365 1370 } 1366 1371 1367 1372 public function test_create_comment_author_ip_defaults_to_remote_addr() { 1373 wp_set_current_user( self::$admin_id ); 1368 1374 $_SERVER['REMOTE_ADDR'] = '127.0.0.2'; 1369 1375 $params = array( … … 1501 1507 1502 1508 public function test_create_item_duplicate() { 1509 wp_set_current_user( self::$subscriber_id ); 1503 1510 $this->factory->comment->create( 1504 1511 array( … … 1509 1516 ) 1510 1517 ); 1511 wp_set_current_user( 0 );1512 1518 1513 1519 $params = array( … … 1530 1536 'comment_status' => 'closed', 1531 1537 )); 1532 wp_set_current_user( 0);1538 wp_set_current_user( self::$subscriber_id ); 1533 1539 1534 1540 $params = array( … … 1547 1553 wp_set_current_user( 0 ); 1548 1554 update_option( 'comment_registration', 1 ); 1555 add_filter( 'rest_allow_anonymous_comments', '__return_true' ); 1549 1556 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); 1550 1557 $request->set_param( 'post', self::$post_id ); … … 1596 1603 1597 1604 public function test_create_comment_two_times() { 1598 wp_set_current_user( 0);1605 add_filter( 'rest_allow_anonymous_comments', '__return_true' ); 1599 1606 1600 1607 $params = array( … … 1633 1640 */ 1634 1641 public function test_create_comment_author_name_too_long() { 1635 wp_set_current_user( 0);1642 wp_set_current_user( self::$subscriber_id ); 1636 1643 1637 1644 $params = array( … … 1656 1663 */ 1657 1664 public function test_create_comment_author_email_too_long() { 1658 wp_set_current_user( 0);1665 wp_set_current_user( self::$subscriber_id ); 1659 1666 1660 1667 $params = array( … … 1679 1686 */ 1680 1687 public function test_create_comment_author_url_too_long() { 1681 wp_set_current_user( 0);1688 wp_set_current_user( self::$subscriber_id ); 1682 1689 1683 1690 $params = array( … … 1702 1709 */ 1703 1710 public function test_create_comment_content_too_long() { 1704 wp_set_current_user( 0);1711 wp_set_current_user( self::$subscriber_id ); 1705 1712 1706 1713 $params = array( … … 1914 1921 1915 1922 public function test_update_comment_invalid_id() { 1916 wp_set_current_user( 0);1923 wp_set_current_user( self::$subscriber_id ); 1917 1924 1918 1925 $params = array( … … 1928 1935 1929 1936 public function test_update_comment_invalid_permission() { 1930 wp_set_current_user( 0);1937 add_filter( 'rest_allow_anonymous_comments', '__return_true' ); 1931 1938 1932 1939 $params = array(
Note: See TracChangeset
for help on using the changeset viewer.