function ServicesResourceCommentTests::testCommentCreate in Services 6.3
Same name and namespace in other branches
- 7.3 tests/functional/ServicesResourceCommentTests.test \ServicesResourceCommentTests::testCommentCreate()
Test create method.
File
- tests/
functional/ ServicesResourceCommentTests.test, line 55
Class
- ServicesResourceCommentTests
- Run test cases for the endpoint with no authentication turned on.
Code
function testCommentCreate() {
$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', $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');
// 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', $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');
}