You are here

function ServicesResourceCommentTests::testCommentUpdateLegacy in Services 7.3

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

Test update method.

TODO: To be removed in future version.

See also

http://drupal.org/node/1083242

File

tests/functional/ServicesResourceCommentTests.test, line 262
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 testCommentUpdateLegacy() {
  $path = $this->endpoint->path;
  $this->privilegedUser = $this
    ->drupalCreateUser(array(
    'administer services',
    'administer comments',
  ));
  $this
    ->drupalLogin($this->privilegedUser);

  // Create node.
  $node = $this
    ->drupalCreateNode();
  $comment_args = $this
    ->getCommentValues($node->nid);
  $comment = (object) $comment_args;
  comment_save($comment);
  $cid = $comment->cid;
  $comment_args['cid'] = $cid;
  $comment_update = $comment_args;
  $comment_update['subject'] = $this
    ->randomString();
  $comment_update['comment_body'][LANGUAGE_NONE][0]['value'] = $this
    ->randomString();
  $response = $this
    ->servicesPut($path . '/comment/' . $cid, array(
    'data' => $comment_update,
  ));
  $comment_load = (array) comment_load($cid);
  $comment_intersect = array_intersect_assoc($comment_load, $comment_update);

  // 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_update, $comment_intersect, 'Comment updated properly.', 'CommentResource: Update');
}