public function RestfulCommentTestCase::testUpdateCommentAsPatch in RESTful 7.2
Test updating a comment (PATCH method).
File
- tests/
RestfulCommentTestCase.test, line 160 - Contains RestfulCommentTestCase
Class
- RestfulCommentTestCase
- @file Contains RestfulCommentTestCase
Code
public function testUpdateCommentAsPatch() {
$resource_manager = restful()
->getResourceManager();
$label = $this
->randomName();
$new_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');
$handler
->setAccount($this->account);
$request = array(
'label' => $new_label,
);
$result = drupal_json_decode(restful()
->getFormatterManager()
->format($handler
->doPatch($id, $request), 'json'));
$result = $result['data'];
$expected_result = array(
array(
'id' => $id,
'label' => $new_label,
'self' => $handler
->versionedUrl($id),
'nid' => $this->node->nid,
'comment_text' => $text,
),
);
$result[0]['comment_text'] = trim(strip_tags($result[0]['comment_text']));
$this
->assertEqual($result, $expected_result);
}