You are here

function ServicesResourceCommentTests::testCommentRetrieve in Services 6.3

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

Test retrieve method.

File

tests/functional/ServicesResourceCommentTests.test, line 140

Class

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

Code

function testCommentRetrieve() {
  $path = $this->endpoint->path;

  // Create node with commenting.
  $settings = array(
    'comment' => COMMENT_NODE_READ_WRITE,
  );
  $node = $this
    ->drupalCreateNode($settings);
  $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);
  $comment['cid'] = $cid;
  $response = $this
    ->servicesGet($path . '/comment/' . $cid);
  $comment_retrieve = (array) $response['body'];
  $comment_intersect = array_intersect_assoc($comment_retrieve, $comment);
  $this
    ->assertEqual($comment, $comment_intersect, t('Comment retrieved properly.'), 'CommentResource: Retrieve');
}