|
@@ 1336-1347 (lines=12) @@
|
| 1333 |
|
$this->assertErrorResponse('rest_cannot_assign_sticky', $response, 403); |
| 1334 |
|
} |
| 1335 |
|
|
| 1336 |
|
public function test_create_post_other_author_without_permission() |
| 1337 |
|
{ |
| 1338 |
|
wp_set_current_user(self::$author_id); |
| 1339 |
|
|
| 1340 |
|
$request = new WP_REST_Request('POST', '/wp/v2/posts'); |
| 1341 |
|
$params = $this->set_post_data( |
| 1342 |
|
array( |
| 1343 |
|
'author' => self::$editor_id, |
| 1344 |
|
) |
| 1345 |
|
); |
| 1346 |
|
$request->set_body_params($params); |
| 1347 |
|
$response = $this->server->dispatch($request); |
| 1348 |
|
|
| 1349 |
|
$this->assertErrorResponse('rest_cannot_edit_others', $response, 403); |
| 1350 |
|
} |
|
@@ 1598-1609 (lines=12) @@
|
| 1595 |
|
$this->assertErrorResponse('rest_invalid_author', $response, 400); |
| 1596 |
|
} |
| 1597 |
|
|
| 1598 |
|
public function test_create_post_invalid_author_without_permission() |
| 1599 |
|
{ |
| 1600 |
|
wp_set_current_user(self::$author_id); |
| 1601 |
|
|
| 1602 |
|
$request = new WP_REST_Request('POST', '/wp/v2/posts'); |
| 1603 |
|
$params = $this->set_post_data( |
| 1604 |
|
array( |
| 1605 |
|
'author' => self::$editor_id, |
| 1606 |
|
) |
| 1607 |
|
); |
| 1608 |
|
$request->set_body_params($params); |
| 1609 |
|
$response = $this->server->dispatch($request); |
| 1610 |
|
|
| 1611 |
|
$this->assertErrorResponse('rest_cannot_edit_others', $response, 403); |
| 1612 |
|
} |
|
@@ 2006-2018 (lines=13) @@
|
| 2003 |
|
$this->assertErrorResponse('rest_cannot_edit', $response, 403); |
| 2004 |
|
} |
| 2005 |
|
|
| 2006 |
|
public function test_update_post_sticky_as_contributor() |
| 2007 |
|
{ |
| 2008 |
|
wp_set_current_user(self::$contributor_id); |
| 2009 |
|
|
| 2010 |
|
$request = new WP_REST_Request('PUT', sprintf('/wp/v2/posts/%d', self::$post_id)); |
| 2011 |
|
$params = $this->set_post_data( |
| 2012 |
|
array( |
| 2013 |
|
'sticky' => true, |
| 2014 |
|
'status' => 'pending', |
| 2015 |
|
) |
| 2016 |
|
); |
| 2017 |
|
$request->set_body_params($params); |
| 2018 |
|
$response = $this->server->dispatch($request); |
| 2019 |
|
|
| 2020 |
|
$this->assertErrorResponse('rest_cannot_edit', $response, 403); |
| 2021 |
|
} |
|
@@ 2081-2092 (lines=12) @@
|
| 2078 |
|
$this->assertFalse(get_post_format($new_post->ID)); |
| 2079 |
|
} |
| 2080 |
|
|
| 2081 |
|
public function test_update_post_with_invalid_format() |
| 2082 |
|
{ |
| 2083 |
|
wp_set_current_user(self::$editor_id); |
| 2084 |
|
|
| 2085 |
|
$request = new WP_REST_Request('PUT', sprintf('/wp/v2/posts/%d', self::$post_id)); |
| 2086 |
|
$params = $this->set_post_data( |
| 2087 |
|
array( |
| 2088 |
|
'format' => 'testformat', |
| 2089 |
|
) |
| 2090 |
|
); |
| 2091 |
|
$request->set_body_params($params); |
| 2092 |
|
$response = $this->server->dispatch($request); |
| 2093 |
|
|
| 2094 |
|
$this->assertErrorResponse('rest_invalid_param', $response, 400); |
| 2095 |
|
} |
|
@@ 2102-2113 (lines=12) @@
|
| 2099 |
|
* |
| 2100 |
|
* https://core.trac.wordpress.org/ticket/38610 |
| 2101 |
|
*/ |
| 2102 |
|
public function test_update_post_with_unsupported_format() |
| 2103 |
|
{ |
| 2104 |
|
wp_set_current_user(self::$editor_id); |
| 2105 |
|
|
| 2106 |
|
$request = new WP_REST_Request('PUT', sprintf('/wp/v2/posts/%d', self::$post_id)); |
| 2107 |
|
$params = $this->set_post_data( |
| 2108 |
|
array( |
| 2109 |
|
'format' => 'link', |
| 2110 |
|
) |
| 2111 |
|
); |
| 2112 |
|
$request->set_body_params($params); |
| 2113 |
|
$response = $this->server->dispatch($request); |
| 2114 |
|
|
| 2115 |
|
$this->assertErrorResponse('rest_invalid_param', $response, 400); |
| 2116 |
|
} |
|
@@ 2147-2158 (lines=12) @@
|
| 2144 |
|
$this->assertEquals(date('Y-m-d', strtotime($expected_modified)), date('Y-m-d', strtotime($new_post->post_modified))); |
| 2145 |
|
} |
| 2146 |
|
|
| 2147 |
|
public function test_update_post_with_invalid_date() |
| 2148 |
|
{ |
| 2149 |
|
wp_set_current_user(self::$editor_id); |
| 2150 |
|
|
| 2151 |
|
$request = new WP_REST_Request('PUT', sprintf('/wp/v2/posts/%d', self::$post_id)); |
| 2152 |
|
$params = $this->set_post_data( |
| 2153 |
|
array( |
| 2154 |
|
'date' => rand_str(), |
| 2155 |
|
) |
| 2156 |
|
); |
| 2157 |
|
$request->set_body_params($params); |
| 2158 |
|
$response = $this->server->dispatch($request); |
| 2159 |
|
|
| 2160 |
|
$this->assertErrorResponse('rest_invalid_param', $response, 400); |
| 2161 |
|
} |
|
@@ 2163-2174 (lines=12) @@
|
| 2160 |
|
$this->assertErrorResponse('rest_invalid_param', $response, 400); |
| 2161 |
|
} |
| 2162 |
|
|
| 2163 |
|
public function test_update_post_with_invalid_date_gmt() |
| 2164 |
|
{ |
| 2165 |
|
wp_set_current_user(self::$editor_id); |
| 2166 |
|
|
| 2167 |
|
$request = new WP_REST_Request('PUT', sprintf('/wp/v2/posts/%d', self::$post_id)); |
| 2168 |
|
$params = $this->set_post_data( |
| 2169 |
|
array( |
| 2170 |
|
'date_gmt' => rand_str(), |
| 2171 |
|
) |
| 2172 |
|
); |
| 2173 |
|
$request->set_body_params($params); |
| 2174 |
|
$response = $this->server->dispatch($request); |
| 2175 |
|
|
| 2176 |
|
$this->assertErrorResponse('rest_invalid_param', $response, 400); |
| 2177 |
|
} |
|
@@ 2337-2349 (lines=13) @@
|
| 2334 |
|
$this->assertEquals('', $data['password']); |
| 2335 |
|
} |
| 2336 |
|
|
| 2337 |
|
public function test_update_post_with_password_and_sticky_fails() |
| 2338 |
|
{ |
| 2339 |
|
wp_set_current_user(self::$editor_id); |
| 2340 |
|
|
| 2341 |
|
$request = new WP_REST_Request('PUT', sprintf('/wp/v2/posts/%d', self::$post_id)); |
| 2342 |
|
$params = $this->set_post_data( |
| 2343 |
|
array( |
| 2344 |
|
'password' => '123', |
| 2345 |
|
'sticky' => true, |
| 2346 |
|
) |
| 2347 |
|
); |
| 2348 |
|
$request->set_body_params($params); |
| 2349 |
|
$response = $this->server->dispatch($request); |
| 2350 |
|
|
| 2351 |
|
$this->assertErrorResponse('rest_invalid_field', $response, 400); |
| 2352 |
|
} |
|
@@ 2354-2367 (lines=14) @@
|
| 2351 |
|
$this->assertErrorResponse('rest_invalid_field', $response, 400); |
| 2352 |
|
} |
| 2353 |
|
|
| 2354 |
|
public function test_update_stick_post_with_password_fails() |
| 2355 |
|
{ |
| 2356 |
|
wp_set_current_user(self::$editor_id); |
| 2357 |
|
|
| 2358 |
|
stick_post(self::$post_id); |
| 2359 |
|
|
| 2360 |
|
$request = new WP_REST_Request('PUT', sprintf('/wp/v2/posts/%d', self::$post_id)); |
| 2361 |
|
$params = $this->set_post_data( |
| 2362 |
|
array( |
| 2363 |
|
'password' => '123', |
| 2364 |
|
) |
| 2365 |
|
); |
| 2366 |
|
$request->set_body_params($params); |
| 2367 |
|
$response = $this->server->dispatch($request); |
| 2368 |
|
|
| 2369 |
|
$this->assertErrorResponse('rest_invalid_field', $response, 400); |
| 2370 |
|
} |