public function ServicesResourceNodetests::testEndpointResourceNodeCreateLegacy in Services 7.3
Same name and namespace in other branches
- 6.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 202 - 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 testEndpointResourceNodeCreateLegacy() {
// Create and log in our privileged user.
$this->privilegedUser = $this
->drupalCreateUser(array(
'administer services',
'bypass node access',
));
$this
->drupalLogin($this->privilegedUser);
$node = array(
'title' => 'testing',
'body' => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomString(),
),
),
),
'type' => 'page',
'name' => $this->privilegedUser->name,
'language' => LANGUAGE_NONE,
);
$responseArray = $this
->servicesPost($this->endpoint->path . '/node', array(
'node' => $node,
));
$nodeResourceCreateReturn = $responseArray['body'];
$this
->assertTrue(isset($nodeResourceCreateReturn['nid']), 'Node was successfully created', 'NodeResource: Create (Legacy)');
$newNode = node_load($nodeResourceCreateReturn['nid']);
$this
->assertTrue($newNode->title = $node['title'], 'Title was the same', 'NodeResource: Create (Legacy)');
$this
->assertTrue($newNode->body = $node['body'], 'Body was the same', 'NodeResource: Create (Legacy)');
}