|
@@ 1045-1069 (lines=25) @@
|
| 1042 |
|
$this->assertEquals(200, $response->get_status()); |
| 1043 |
|
} |
| 1044 |
|
|
| 1045 |
|
public function test_create_item() |
| 1046 |
|
{ |
| 1047 |
|
wp_set_current_user(self::$admin_id); |
| 1048 |
|
|
| 1049 |
|
$params = array( |
| 1050 |
|
'post' => self::$post_id, |
| 1051 |
|
'author_name' => 'Comic Book Guy', |
| 1052 |
|
'author_email' => '[email protected]', |
| 1053 |
|
'author_url' => 'http://androidsdungeon.com', |
| 1054 |
|
'content' => 'Worst Comment Ever!', |
| 1055 |
|
'date' => '2014-11-07T10:14:25', |
| 1056 |
|
); |
| 1057 |
|
|
| 1058 |
|
$request = new WP_REST_Request('POST', '/wp/v2/comments'); |
| 1059 |
|
$request->add_header('content-type', 'application/json'); |
| 1060 |
|
$request->set_body(wp_json_encode($params)); |
| 1061 |
|
|
| 1062 |
|
$response = $this->server->dispatch($request); |
| 1063 |
|
$this->assertEquals(201, $response->get_status()); |
| 1064 |
|
|
| 1065 |
|
$data = $response->get_data(); |
| 1066 |
|
$this->check_comment_data($data, 'edit', $response->get_links()); |
| 1067 |
|
$this->assertEquals('hold', $data['status']); |
| 1068 |
|
$this->assertEquals('2014-11-07T10:14:25', $data['date']); |
| 1069 |
|
$this->assertEquals(self::$post_id, $data['post']); |
| 1070 |
|
} |
| 1071 |
|
|
| 1072 |
|
public function test_create_item_using_accepted_content_raw_value() |
|
@@ 1398-1421 (lines=24) @@
|
| 1395 |
|
$this->assertEquals($author->user_url, $comment->comment_author_url); |
| 1396 |
|
} |
| 1397 |
|
|
| 1398 |
|
public function test_create_comment_other_user() |
| 1399 |
|
{ |
| 1400 |
|
wp_set_current_user(self::$admin_id); |
| 1401 |
|
|
| 1402 |
|
$params = array( |
| 1403 |
|
'post' => self::$post_id, |
| 1404 |
|
'author_name' => 'Homer Jay Simpson', |
| 1405 |
|
'author_email' => '[email protected]', |
| 1406 |
|
'author_url' => 'http://compuglobalhypermeganet.com', |
| 1407 |
|
'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.', |
| 1408 |
|
'author' => self::$subscriber_id, |
| 1409 |
|
); |
| 1410 |
|
|
| 1411 |
|
$request = new WP_REST_Request('POST', '/wp/v2/comments'); |
| 1412 |
|
$request->add_header('content-type', 'application/json'); |
| 1413 |
|
$request->set_body(wp_json_encode($params)); |
| 1414 |
|
$response = $this->server->dispatch($request); |
| 1415 |
|
|
| 1416 |
|
$this->assertEquals(201, $response->get_status()); |
| 1417 |
|
$data = $response->get_data(); |
| 1418 |
|
$this->assertEquals(self::$subscriber_id, $data['author']); |
| 1419 |
|
$this->assertEquals('Homer Jay Simpson', $data['author_name']); |
| 1420 |
|
$this->assertEquals('[email protected]', $data['author_email']); |
| 1421 |
|
$this->assertEquals('http://compuglobalhypermeganet.com', $data['author_url']); |
| 1422 |
|
} |
| 1423 |
|
|
| 1424 |
|
public function test_create_comment_other_user_without_permission() |