public function RestfulCommentTestCase::testDeleteComment in RESTful 7.2
Test deleting a comment (DELETE method).
File
- tests/
RestfulCommentTestCase.test, line 203 - Contains RestfulCommentTestCase
Class
- RestfulCommentTestCase
- @file Contains RestfulCommentTestCase
Code
public function testDeleteComment() {
$resource_manager = restful()
->getResourceManager();
$label = $this
->randomName();
$text = $this
->randomName();
$settings = array(
'node_type' => 'comment_node_article',
'nid' => $this->node->nid,
'uid' => $this->account->uid,
'subject' => $label,
);
$settings['comment_text'][LANGUAGE_NONE][0]['value'] = $text;
$comment = $this
->createComment($settings);
$id = $comment->cid;
$handler = $resource_manager
->getPlugin('comments:1.0');
// Set a different user from the comment user, as only the administer
// can delete comments.
$user = $this
->drupalCreateUser(array(
'administer comments',
));
$handler
->setAccount($user);
$handler
->doDelete($id);
$result = !comment_load($id);
$this
->assertTrue($result, 'Comment deleted.');
}