function ServicesResourceNodetests::update_node in Services 7.3
Helper function to perform node updates.
@parm $exclude_type Integer how should the type value be treated.
1 call to ServicesResourceNodetests::update_node()
- ServicesResourceNodetests::testEndpointResourceNodeUpdate in tests/
functional/ ServicesResourceNodeTests.test - Testing node_resource Update.
File
- tests/
functional/ ServicesResourceNodeTests.test, line 340 - Call the endpoint tests when no authentication is being used.
Class
- ServicesResourceNodetests
- Run test cases for the endpoint with no authentication turned on.
Code
function update_node($exclude_type) {
$node = $this
->drupalCreateNode();
$node_update = (array) $node;
$node_update['title'] = $this
->randomName();
$node_update['body'][LANGUAGE_NONE][0]['value'] = $this
->randomName();
if ($exclude_type == SERVICES_NODE_TYPE_EMPTY) {
$node_update['type'] = '';
}
elseif ($exclude_type == SERVICES_NODE_TYPE_REMOVED) {
unset($node_update['type']);
}
$responseArray = $this
->servicesPut($this->endpoint->path . '/node/' . $node->nid, $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');
$this
->assertEqual($nodeAfterUpdate->title, $node_update['title'], 'Title is the same', 'NodeResource: Update');
$this
->assertEqual($nodeAfterUpdate->body[LANGUAGE_NONE][0]['value'], $node_update['body'][LANGUAGE_NONE][0]['value'], 'Body is the same', 'NodeResource: Update');
}