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