public function RestfulCommentTestCase::testRetrieve in RESTful 7.2
Test creating a comment (GET method).
File
- tests/
RestfulCommentTestCase.test, line 90 - Contains RestfulCommentTestCase
Class
- RestfulCommentTestCase
- @file Contains RestfulCommentTestCase
Code
public function testRetrieve() {
$resource_manager = restful()
->getResourceManager();
$label = $this
->randomName();
$settings = array(
'node_type' => 'comment_node_article',
'nid' => $this->node->nid,
'uid' => $this->account->uid,
'subject' => $label,
);
$comment = $this
->createComment($settings);
$id = $comment->cid;
$handler = $resource_manager
->getPlugin('comments:1.0');
$result = drupal_json_decode(restful()
->getFormatterManager()
->format($handler
->doGet($id), 'json'));
$result = $result['data'];
$comment = $result[0];
$this
->assertEqual($comment['nid'], $this->node->nid, 'Correct nid get.');
$this
->assertEqual($comment['label'], $label, 'Correct subject get.');
}