public function ServicesResourceNodetests::testEndpointResourceNodeCreate in Services 7.3
Same name and namespace in other branches
- 6.3 tests/functional/ServicesResourceNodeTests.test \ServicesResourceNodetests::testEndpointResourceNodeCreate()
Testing node_resource Create.
File
- tests/
functional/ ServicesResourceNodeTests.test, line 172 - 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 testEndpointResourceNodeCreate() {
// 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', $node);
$nodeResourceCreateReturn = $responseArray['body'];
$this
->assertTrue(isset($nodeResourceCreateReturn['nid']), 'Node was successfully created', 'NodeResource: Create');
$newNode = node_load($nodeResourceCreateReturn['nid']);
$this
->assertTrue($newNode->title = $node['title'], 'Title was the same', 'NodeResource: Create');
$this
->assertTrue($newNode->body = $node['body'], 'Body was the same', 'NodeResource: Create');
}