function ServicesResourceCommentTests::testCommentCountNew in Services 6.3
Same name and namespace in other branches
- 7.3 tests/functional/ServicesResourceCommentTests.test \ServicesResourceCommentTests::testCommentCountNew()
Test countNew method.
File
- tests/
functional/ ServicesResourceCommentTests.test, line 297
Class
- ServicesResourceCommentTests
- Run test cases for the endpoint with no authentication turned on.
Code
function testCommentCountNew() {
$path = $this->endpoint->path;
// Generate comments.
$settings = array(
'comment' => COMMENT_NODE_READ_WRITE,
);
$node = $this
->drupalCreateNode($settings);
for ($i = 0; $i < 5; $i++) {
$comment = array(
'cid' => NULL,
'uid' => $this->privileged_user->uid,
'nid' => $node->nid,
'subject' => $this
->randomString(),
'comment' => $this
->randomString(),
'format' => 1,
);
$cid = comment_save((array) $comment);
$comments[] = _comment_load($cid);
sleep(1);
}
$response = $this
->servicesPost($path . '/comment/countNew', array(
'nid' => $node->nid,
));
$this
->assertEqual($response['body'], 5, t('Received number of all new comments.'), 'CommentResource: countNew');
$since = $comments[2]->timestamp;
$response = $this
->servicesPost($path . '/comment/countNew', array(
'nid' => $node->nid,
'since' => $since,
));
$this
->assertEqual($response['body'], 2, t('Received number of new comments.'), 'CommentResource: countNew');
}