|
@@ 1445-1463 (lines=19) @@
|
| 1442 |
|
$this->assertErrorResponse('rest_comment_invalid_author', $response, 403); |
| 1443 |
|
} |
| 1444 |
|
|
| 1445 |
|
public function test_create_comment_invalid_post() |
| 1446 |
|
{ |
| 1447 |
|
wp_set_current_user(self::$subscriber_id); |
| 1448 |
|
|
| 1449 |
|
$params = array( |
| 1450 |
|
'post' => 'some-slug', |
| 1451 |
|
'author_name' => 'Homer Jay Simpson', |
| 1452 |
|
'author_email' => '[email protected]', |
| 1453 |
|
'author_url' => 'http://compuglobalhypermeganet.com', |
| 1454 |
|
'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.', |
| 1455 |
|
'author' => self::$subscriber_id, |
| 1456 |
|
); |
| 1457 |
|
|
| 1458 |
|
$request = new WP_REST_Request('POST', '/wp/v2/comments'); |
| 1459 |
|
$request->add_header('content-type', 'application/json'); |
| 1460 |
|
$request->set_body(wp_json_encode($params)); |
| 1461 |
|
$response = $this->server->dispatch($request); |
| 1462 |
|
|
| 1463 |
|
$this->assertErrorResponse('rest_invalid_param', $response, 400); |
| 1464 |
|
} |
| 1465 |
|
|
| 1466 |
|
public function test_create_comment_status_without_permission() |
|
@@ 1466-1485 (lines=20) @@
|
| 1463 |
|
$this->assertErrorResponse('rest_invalid_param', $response, 400); |
| 1464 |
|
} |
| 1465 |
|
|
| 1466 |
|
public function test_create_comment_status_without_permission() |
| 1467 |
|
{ |
| 1468 |
|
wp_set_current_user(self::$subscriber_id); |
| 1469 |
|
|
| 1470 |
|
$params = array( |
| 1471 |
|
'post' => self::$post_id, |
| 1472 |
|
'author_name' => 'Homer Jay Simpson', |
| 1473 |
|
'author_email' => '[email protected]', |
| 1474 |
|
'author_url' => 'http://compuglobalhypermeganet.com', |
| 1475 |
|
'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.', |
| 1476 |
|
'author' => self::$subscriber_id, |
| 1477 |
|
'status' => 'approved', |
| 1478 |
|
); |
| 1479 |
|
|
| 1480 |
|
$request = new WP_REST_Request('POST', '/wp/v2/comments'); |
| 1481 |
|
$request->add_header('content-type', 'application/json'); |
| 1482 |
|
$request->set_body(wp_json_encode($params)); |
| 1483 |
|
$response = $this->server->dispatch($request); |
| 1484 |
|
|
| 1485 |
|
$this->assertErrorResponse('rest_comment_invalid_status', $response, 403); |
| 1486 |
|
} |
| 1487 |
|
|
| 1488 |
|
public function test_create_comment_with_status_IP_and_user_agent() |
|
@@ 1565-1583 (lines=19) @@
|
| 1562 |
|
$this->assertEquals('127.0.0.3', $new_comment->comment_author_IP); |
| 1563 |
|
} |
| 1564 |
|
|
| 1565 |
|
public function test_create_comment_invalid_author_IP() |
| 1566 |
|
{ |
| 1567 |
|
wp_set_current_user(self::$admin_id); |
| 1568 |
|
|
| 1569 |
|
$params = array( |
| 1570 |
|
'post' => self::$post_id, |
| 1571 |
|
'author_name' => 'Comic Book Guy', |
| 1572 |
|
'author_email' => '[email protected]', |
| 1573 |
|
'author_url' => 'http://androidsdungeon.com', |
| 1574 |
|
'author_ip' => '867.5309', |
| 1575 |
|
'content' => 'Worst Comment Ever!', |
| 1576 |
|
'status' => 'approved', |
| 1577 |
|
); |
| 1578 |
|
$request = new WP_REST_Request('POST', '/wp/v2/comments'); |
| 1579 |
|
$request->add_header('content-type', 'application/json'); |
| 1580 |
|
$request->set_body(wp_json_encode($params)); |
| 1581 |
|
|
| 1582 |
|
$response = $this->server->dispatch($request); |
| 1583 |
|
$this->assertErrorResponse('rest_invalid_param', $response, 400); |
| 1584 |
|
} |
| 1585 |
|
|
| 1586 |
|
public function test_create_comment_author_ip_no_permission() |
|
@@ 1586-1601 (lines=16) @@
|
| 1583 |
|
$this->assertErrorResponse('rest_invalid_param', $response, 400); |
| 1584 |
|
} |
| 1585 |
|
|
| 1586 |
|
public function test_create_comment_author_ip_no_permission() |
| 1587 |
|
{ |
| 1588 |
|
wp_set_current_user(self::$subscriber_id); |
| 1589 |
|
$params = array( |
| 1590 |
|
'author_name' => 'Comic Book Guy', |
| 1591 |
|
'author_email' => '[email protected]', |
| 1592 |
|
'author_url' => 'http://androidsdungeon.com', |
| 1593 |
|
'author_ip' => '10.0.10.1', |
| 1594 |
|
'content' => 'Worst Comment Ever!', |
| 1595 |
|
'status' => 'approved', |
| 1596 |
|
); |
| 1597 |
|
$request = new WP_REST_Request('POST', '/wp/v2/comments'); |
| 1598 |
|
$request->add_header('content-type', 'application/json'); |
| 1599 |
|
$request->set_body(wp_json_encode($params)); |
| 1600 |
|
$response = $this->server->dispatch($request); |
| 1601 |
|
$this->assertErrorResponse('rest_comment_invalid_author_ip', $response, 403); |
| 1602 |
|
} |
| 1603 |
|
|
| 1604 |
|
public function test_create_comment_author_ip_defaults_to_remote_addr() |
|
@@ 1663-1681 (lines=19) @@
|
| 1660 |
|
$this->assertErrorResponse('rest_comment_invalid_post_id', $response, 403); |
| 1661 |
|
} |
| 1662 |
|
|
| 1663 |
|
public function test_create_comment_invalid_post_id() |
| 1664 |
|
{ |
| 1665 |
|
wp_set_current_user(self::$admin_id); |
| 1666 |
|
|
| 1667 |
|
$params = array( |
| 1668 |
|
'author_name' => 'Homer Jay Simpson', |
| 1669 |
|
'author_email' => '[email protected]', |
| 1670 |
|
'author_url' => 'http://compuglobalhypermeganet.com', |
| 1671 |
|
'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.', |
| 1672 |
|
'status' => 'approved', |
| 1673 |
|
'post' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, |
| 1674 |
|
); |
| 1675 |
|
|
| 1676 |
|
$request = new WP_REST_Request('POST', '/wp/v2/comments'); |
| 1677 |
|
$request->add_header('content-type', 'application/json'); |
| 1678 |
|
$request->set_body(wp_json_encode($params)); |
| 1679 |
|
|
| 1680 |
|
$response = $this->server->dispatch($request); |
| 1681 |
|
$this->assertErrorResponse('rest_comment_invalid_post_id', $response, 403); |
| 1682 |
|
} |
| 1683 |
|
|
| 1684 |
|
public function test_create_comment_draft_post() |
|
@@ 1937-1955 (lines=19) @@
|
| 1934 |
|
/** |
| 1935 |
|
* @ticket 38477 |
| 1936 |
|
*/ |
| 1937 |
|
public function test_create_comment_author_name_too_long() |
| 1938 |
|
{ |
| 1939 |
|
wp_set_current_user(self::$subscriber_id); |
| 1940 |
|
|
| 1941 |
|
$params = array( |
| 1942 |
|
'post' => self::$post_id, |
| 1943 |
|
'author_name' => rand_long_str(246), |
| 1944 |
|
'author_email' => '[email protected]', |
| 1945 |
|
'author_url' => 'http://jazz.gingivitis.com', |
| 1946 |
|
'content' => 'This isn\'t a saxophone. It\'s an umbrella.', |
| 1947 |
|
'date' => '1995-04-30T10:22:00', |
| 1948 |
|
); |
| 1949 |
|
$request = new WP_REST_Request('POST', '/wp/v2/comments'); |
| 1950 |
|
|
| 1951 |
|
$request->add_header('content-type', 'application/json'); |
| 1952 |
|
$request->set_body(wp_json_encode($params)); |
| 1953 |
|
$response = $this->server->dispatch($request); |
| 1954 |
|
|
| 1955 |
|
$this->assertErrorResponse('comment_author_column_length', $response, 400); |
| 1956 |
|
} |
| 1957 |
|
|
| 1958 |
|
/** |
|
@@ 1961-1979 (lines=19) @@
|
| 1958 |
|
/** |
| 1959 |
|
* @ticket 38477 |
| 1960 |
|
*/ |
| 1961 |
|
public function test_create_comment_author_email_too_long() |
| 1962 |
|
{ |
| 1963 |
|
wp_set_current_user(self::$subscriber_id); |
| 1964 |
|
|
| 1965 |
|
$params = array( |
| 1966 |
|
'post' => self::$post_id, |
| 1967 |
|
'author_name' => 'Bleeding Gums Murphy', |
| 1968 |
|
'author_email' => 'murphy@' . rand_long_str(190) . '.com', |
| 1969 |
|
'author_url' => 'http://jazz.gingivitis.com', |
| 1970 |
|
'content' => 'This isn\'t a saxophone. It\'s an umbrella.', |
| 1971 |
|
'date' => '1995-04-30T10:22:00', |
| 1972 |
|
); |
| 1973 |
|
$request = new WP_REST_Request('POST', '/wp/v2/comments'); |
| 1974 |
|
|
| 1975 |
|
$request->add_header('content-type', 'application/json'); |
| 1976 |
|
$request->set_body(wp_json_encode($params)); |
| 1977 |
|
$response = $this->server->dispatch($request); |
| 1978 |
|
|
| 1979 |
|
$this->assertErrorResponse('comment_author_email_column_length', $response, 400); |
| 1980 |
|
} |
| 1981 |
|
|
| 1982 |
|
/** |
|
@@ 1985-2003 (lines=19) @@
|
| 1982 |
|
/** |
| 1983 |
|
* @ticket 38477 |
| 1984 |
|
*/ |
| 1985 |
|
public function test_create_comment_author_url_too_long() |
| 1986 |
|
{ |
| 1987 |
|
wp_set_current_user(self::$subscriber_id); |
| 1988 |
|
|
| 1989 |
|
$params = array( |
| 1990 |
|
'post' => self::$post_id, |
| 1991 |
|
'author_name' => 'Bleeding Gums Murphy', |
| 1992 |
|
'author_email' => '[email protected]', |
| 1993 |
|
'author_url' => 'http://jazz.' . rand_long_str(185) . '.com', |
| 1994 |
|
'content' => 'This isn\'t a saxophone. It\'s an umbrella.', |
| 1995 |
|
'date' => '1995-04-30T10:22:00', |
| 1996 |
|
); |
| 1997 |
|
$request = new WP_REST_Request('POST', '/wp/v2/comments'); |
| 1998 |
|
|
| 1999 |
|
$request->add_header('content-type', 'application/json'); |
| 2000 |
|
$request->set_body(wp_json_encode($params)); |
| 2001 |
|
$response = $this->server->dispatch($request); |
| 2002 |
|
|
| 2003 |
|
$this->assertErrorResponse('comment_author_url_column_length', $response, 400); |
| 2004 |
|
} |
| 2005 |
|
|
| 2006 |
|
/** |
|
@@ 2009-2027 (lines=19) @@
|
| 2006 |
|
/** |
| 2007 |
|
* @ticket 38477 |
| 2008 |
|
*/ |
| 2009 |
|
public function test_create_comment_content_too_long() |
| 2010 |
|
{ |
| 2011 |
|
wp_set_current_user(self::$subscriber_id); |
| 2012 |
|
|
| 2013 |
|
$params = array( |
| 2014 |
|
'post' => self::$post_id, |
| 2015 |
|
'author_name' => 'Bleeding Gums Murphy', |
| 2016 |
|
'author_email' => '[email protected]', |
| 2017 |
|
'author_url' => 'http://jazz.gingivitis.com', |
| 2018 |
|
'content' => rand_long_str(66525), |
| 2019 |
|
'date' => '1995-04-30T10:22:00', |
| 2020 |
|
); |
| 2021 |
|
$request = new WP_REST_Request('POST', '/wp/v2/comments'); |
| 2022 |
|
|
| 2023 |
|
$request->add_header('content-type', 'application/json'); |
| 2024 |
|
$request->set_body(wp_json_encode($params)); |
| 2025 |
|
$response = $this->server->dispatch($request); |
| 2026 |
|
|
| 2027 |
|
$this->assertErrorResponse('comment_content_column_length', $response, 400); |
| 2028 |
|
} |
| 2029 |
|
|
| 2030 |
|
public function test_create_comment_without_password() |
|
@@ 2050-2067 (lines=18) @@
|
| 2047 |
|
$this->assertErrorResponse('rest_cannot_read_post', $response, 403); |
| 2048 |
|
} |
| 2049 |
|
|
| 2050 |
|
public function test_create_comment_with_password() |
| 2051 |
|
{ |
| 2052 |
|
add_filter('rest_allow_anonymous_comments', '__return_true'); |
| 2053 |
|
|
| 2054 |
|
$params = array( |
| 2055 |
|
'post' => self::$password_id, |
| 2056 |
|
'author_name' => 'Bleeding Gums Murphy', |
| 2057 |
|
'author_email' => '[email protected]', |
| 2058 |
|
'author_url' => 'http://jazz.gingivitis.com', |
| 2059 |
|
'content' => 'This isn\'t a saxophone. It\'s an umbrella.', |
| 2060 |
|
'password' => 'toomanysecrets', |
| 2061 |
|
); |
| 2062 |
|
$request = new WP_REST_Request('POST', '/wp/v2/comments'); |
| 2063 |
|
|
| 2064 |
|
$request->add_header('content-type', 'application/json'); |
| 2065 |
|
$request->set_body(wp_json_encode($params)); |
| 2066 |
|
$response = $this->server->dispatch($request); |
| 2067 |
|
$this->assertEquals(201, $response->get_status()); |
| 2068 |
|
} |
| 2069 |
|
|
| 2070 |
|
public function test_update_item() |