You are here

function ServicesResourceCommentTests::testCommentCountAll in Services 6.3

Same name and namespace in other branches
  1. 7.3 tests/functional/ServicesResourceCommentTests.test \ServicesResourceCommentTests::testCommentCountAll()

Test countAll method.

File

tests/functional/ServicesResourceCommentTests.test, line 273

Class

ServicesResourceCommentTests
Run test cases for the endpoint with no authentication turned on.

Code

function testCommentCountAll() {
  $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);
  }
  $response = $this
    ->servicesPost($path . '/comment/countAll', array(
    'nid' => $node->nid,
  ));
  $this
    ->assertEqual($response['body'], 5, t('Counted number of comments properly.'), 'CommentResource: countAll');
}