function ServicesResourceCommentTests::testCommentCreateLegacy in Services 6.3
Same name and namespace in other branches
- 7.3 tests/functional/ServicesResourceCommentTests.test \ServicesResourceCommentTests::testCommentCreateLegacy()
Test create comment (Legacy).
TODO: To be removed in future version.
See also
http://drupal.org/node/1083242
File
- tests/
functional/ ServicesResourceCommentTests.test, line 99
Class
- ServicesResourceCommentTests
- Run test cases for the endpoint with no authentication turned on.
Code
function testCommentCreateLegacy() {
$path = $this->endpoint->path;
// Create node with commenting.
$settings = array(
'comment' => COMMENT_NODE_READ_WRITE,
);
$node = $this
->drupalCreateNode($settings);
$comment = array(
'uid' => $this->privileged_user->uid,
'nid' => $node->nid,
'subject' => $this
->randomString(),
'comment' => $this
->randomString(),
);
$response = $this
->servicesPost($path . '/comment', array(
'comment' => $comment,
));
$cid = $response['body']['cid'];
$comment['cid'] = $cid;
$comment_load = (array) _comment_load($cid);
$comment_intersect = array_intersect_assoc($comment_load, $comment);
$this
->assertEqual($comment, $comment_intersect, t('Comment created properly.'), 'CommentResource: Create (Legacy)');
// Try to create node with not allowed filter.
$comment = array(
'uid' => $this->privileged_user->uid,
'nid' => $node->nid,
'subject' => $this
->randomString(),
'comment' => $this
->randomString(),
// Full HTML format.
'format' => 2,
);
$response_array = $this
->servicesPost($this->endpoint->path . '/comment', array(
'comment' => $comment,
));
$new_comment = _comment_load($response_array['body']['cid']);
$this
->assertNotEqual($new_comment->format, $comment['format'], t('Full HTML format has not been applied.'), 'CommentResource: Create (Legacy)');
}