You are here

public function ServicesResourceNodetests::testEndpointResourceNodeCreateLegacy in Services 6.3

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

Testing node_resource Create (Legacy).

TODO: To be removed in future version.

See also

http://drupal.org/node/1083242

File

tests/functional/ServicesResourceNodeTests.test, line 164

Class

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

Code

public function testEndpointResourceNodeCreateLegacy() {

  // Create and log in our privileged user.
  $this->privilegedUser = $this
    ->drupalCreateUser(array(
    'administer services',
    'administer nodes',
  ));
  $this
    ->drupalLogin($this->privilegedUser);
  $node = array(
    'title' => 'testing',
    'body' => 'bodytest',
    'type' => 'story',
    'name' => $this->privilegedUser->name,
  );
  $responseArray = $this
    ->servicesPost($this->endpoint->path . '/node', array(
    'node' => $node,
  ));
  $nodeResourceCreateReturn = $responseArray['body'];
  $this
    ->assertTrue(isset($nodeResourceCreateReturn['nid']), t('Node was successfully created'), 'NodeResource: Create (Legacy)');
  if (isset($nodeResourceCreateReturn['nid'])) {
    $newNode = node_load($nodeResourceCreateReturn['nid']);
    $this
      ->assertTrue($newNode->title = $node['title'], t('Title was the same'), 'NodeResource: Create (Legacy)');
    $this
      ->assertTrue($newNode->body = $node['body'], t('Body was the same'), 'NodeResource: Create (Legacy)');
  }
}