You are here

public function ServicesResourceNodetests::testEndpointResourceNodeUpdateLegacy in Services 7.3

Same name and namespace in other branches
  1. 6.3 tests/functional/ServicesResourceNodeTests.test \ServicesResourceNodetests::testEndpointResourceNodeUpdateLegacy()

Testing node_resource Update (Legacy).

TODO: To be removed in future version.

See also

http://drupal.org/node/1083242

File

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

Class

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

Code

public function testEndpointResourceNodeUpdateLegacy() {

  // Create and log in our privileged user.
  $this->privilegedUser = $this
    ->drupalCreateUser(array(
    'administer services',
    'bypass node access',
  ));
  $this
    ->drupalLogin($this->privilegedUser);
  $node = $this
    ->drupalCreateNode();
  $node_update = (array) $node;
  $node_update['title'] = $this
    ->randomName();
  $node_update['body'][LANGUAGE_NONE][0]['value'] = $this
    ->randomName();
  $responseArray = $this
    ->servicesPut($this->endpoint->path . '/node/' . $node->nid, array(
    'node' => $node_update,
  ));

  // Load node not from cache.
  $nodeAfterUpdate = node_load($responseArray['body']['nid'], NULL, TRUE);
  $this
    ->assertTrue(isset($nodeAfterUpdate->nid), 'Node was successfully updated', 'NodeResource: Updated (legacy)');
  $this
    ->assertEqual($nodeAfterUpdate->title, $node_update['title'], 'Title is the same', 'NodeResource: Update (legacy)');
  $this
    ->assertEqual($nodeAfterUpdate->body[LANGUAGE_NONE][0]['value'], $node_update['body'][LANGUAGE_NONE][0]['value'], 'Body is the same', 'NodeResource: Update (legacy)');
}