You are here

function ServicesResourceCommentTests::testCommentUpdate in Services 6.3

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

Test update method.

File

tests/functional/ServicesResourceCommentTests.test, line 171

Class

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

Code

function testCommentUpdate() {
  $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($comment);
  $comment['cid'] = $cid;
  $comment_update = $comment;
  $comment_update['subject'] = $this
    ->randomString();
  $comment_update['comment'] = $this
    ->randomString();
  $response = $this
    ->servicesPut($path . '/comment/' . $cid, $comment_update);
  $comment_load = (array) _comment_load($cid);
  $comment_intersect = array_intersect_assoc($comment_load, $comment_update);
  $this
    ->assertEqual($comment_update, $comment_intersect, t('Comment updated properly.'), 'CommentResource: Update');
}