function ServicesResourceCommentTests::testCommentUpdate in Services 7.3
Same name and namespace in other branches
- 6.3 tests/functional/ServicesResourceCommentTests.test \ServicesResourceCommentTests::testCommentUpdate()
Test update method.
File
- tests/
functional/ ServicesResourceCommentTests.test, line 222 - Call the endpoint tests when no authentication is being used.
Class
- ServicesResourceCommentTests
- Run test cases for the endpoint with no authentication turned on.
Code
function testCommentUpdate() {
$path = $this->endpoint->path;
$this->privilegedUser = $this
->drupalCreateUser(array(
'administer services',
'administer comments',
));
$this
->drupalLogin($this->privilegedUser);
// Create node.
$node = $this
->drupalCreateNode();
$comment_args = $this
->getCommentValues($node->nid);
$comment = (object) $comment_args;
comment_save($comment);
$cid = $comment->cid;
$comment_args['cid'] = $cid;
$comment_update = $comment_args;
$comment_update['subject'] = $this
->randomString();
$comment_update['comment_body'][LANGUAGE_NONE][0]['value'] = $this
->randomString();
$response = $this
->servicesPut($path . '/comment/' . $cid, $comment_update);
$comment_load = (array) comment_load($cid);
$comment_intersect = array_intersect_assoc($comment_load, $comment_update);
// Unset save_value as we don't have this key in arguments.
unset($comment_intersect['comment_body'][LANGUAGE_NONE][0]['safe_value']);
$this
->assertEqual($comment_update, $comment_intersect, 'Comment updated properly.', 'CommentResource: Update');
}