You are here

function ServicesResourceCommentTests::testCommentRetrieve in Services 7.3

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

Test retrieve method.

File

tests/functional/ServicesResourceCommentTests.test, line 194
Call the endpoint tests when no authentication is being used.

Class

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

Code

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

  // Create node.
  $node = $this
    ->drupalCreateNode();
  $comment_args = $this
    ->getCommentValues($node->nid);
  $comment = (object) $comment_args;
  comment_save($comment);
  $comment_args['cid'] = $comment->cid;
  $response = $this
    ->servicesGet($path . '/comment/' . $comment->cid);
  $comment_retrieve = (array) $response['body'];
  $comment_intersect = array_intersect_assoc($comment_retrieve, $comment_args);

  // Unset save_value as we don't have this key in arguments.
  unset($comment_intersect['comment_body'][LANGUAGE_NONE][0]['safe_value']);
  $this
    ->assertEqual($comment_args, $comment_intersect, 'Comment retrieved properly.', 'CommentResource: Retrieve');
}