function RestfulCreateNodeTestCase::testCreateNode in RESTful 7
Same name and namespace in other branches
- 7.2 tests/RestfulCreateNodeTestCase.test \RestfulCreateNodeTestCase::testCreateNode()
Test creating a node (POST method).
File
- tests/
RestfulCreateNodeTestCase.test, line 25 - Contains RestfulCreateNodeTestCase
Class
- RestfulCreateNodeTestCase
- @file Contains RestfulCreateNodeTestCase
Code
function testCreateNode() {
$user1 = $this
->drupalCreateUser();
$this
->drupalLogin($user1);
$handler = restful_get_restful_handler('articles');
// Set a different user from the logged in user, to assert the node's author
// is set correctly.
$user2 = $this
->drupalCreateUser(array(
'create article content',
));
$handler
->setAccount($user2);
$text1 = $this
->randomName();
$request = array(
'label' => $text1,
);
$result = $handler
->post('', $request);
$node = node_load($result[0]['id']);
$this
->assertEqual($node->uid, $user2->uid, 'Correct user was set to be the author of the node.');
}