|
@@ 1890-1909 (lines=20) @@
|
| 1887 |
|
return $caps; |
| 1888 |
|
} |
| 1889 |
|
|
| 1890 |
|
public function test_update_item() |
| 1891 |
|
{ |
| 1892 |
|
wp_set_current_user(self::$editor_id); |
| 1893 |
|
|
| 1894 |
|
$request = new WP_REST_Request('PUT', sprintf('/wp/v2/posts/%d', self::$post_id)); |
| 1895 |
|
$request->add_header('content-type', 'application/x-www-form-urlencoded'); |
| 1896 |
|
$params = $this->set_post_data(); |
| 1897 |
|
$request->set_body_params($params); |
| 1898 |
|
$response = $this->server->dispatch($request); |
| 1899 |
|
|
| 1900 |
|
$this->check_update_post_response($response); |
| 1901 |
|
$new_data = $response->get_data(); |
| 1902 |
|
$this->assertEquals(self::$post_id, $new_data['id']); |
| 1903 |
|
$this->assertEquals($params['title'], $new_data['title']['raw']); |
| 1904 |
|
$this->assertEquals($params['content'], $new_data['content']['raw']); |
| 1905 |
|
$this->assertEquals($params['excerpt'], $new_data['excerpt']['raw']); |
| 1906 |
|
$post = get_post(self::$post_id); |
| 1907 |
|
$this->assertEquals($params['title'], $post->post_title); |
| 1908 |
|
$this->assertEquals($params['content'], $post->post_content); |
| 1909 |
|
$this->assertEquals($params['excerpt'], $post->post_excerpt); |
| 1910 |
|
} |
| 1911 |
|
|
| 1912 |
|
public function test_update_item_no_change() |
|
@@ 1929-1948 (lines=20) @@
|
| 1926 |
|
$this->check_update_post_response($response); |
| 1927 |
|
} |
| 1928 |
|
|
| 1929 |
|
public function test_rest_update_post() |
| 1930 |
|
{ |
| 1931 |
|
wp_set_current_user(self::$editor_id); |
| 1932 |
|
|
| 1933 |
|
$request = new WP_REST_Request('PUT', sprintf('/wp/v2/posts/%d', self::$post_id)); |
| 1934 |
|
$request->add_header('content-type', 'application/json'); |
| 1935 |
|
$params = $this->set_post_data(); |
| 1936 |
|
$request->set_body(wp_json_encode($params)); |
| 1937 |
|
$response = $this->server->dispatch($request); |
| 1938 |
|
|
| 1939 |
|
$this->check_update_post_response($response); |
| 1940 |
|
$new_data = $response->get_data(); |
| 1941 |
|
$this->assertEquals(self::$post_id, $new_data['id']); |
| 1942 |
|
$this->assertEquals($params['title'], $new_data['title']['raw']); |
| 1943 |
|
$this->assertEquals($params['content'], $new_data['content']['raw']); |
| 1944 |
|
$this->assertEquals($params['excerpt'], $new_data['excerpt']['raw']); |
| 1945 |
|
$post = get_post(self::$post_id); |
| 1946 |
|
$this->assertEquals($params['title'], $post->post_title); |
| 1947 |
|
$this->assertEquals($params['content'], $post->post_content); |
| 1948 |
|
$this->assertEquals($params['excerpt'], $post->post_excerpt); |
| 1949 |
|
} |
| 1950 |
|
|
| 1951 |
|
public function test_rest_update_post_raw() |