RestfulCreateNodeTestCase.test in RESTful 7
Same filename and directory in other branches
Contains RestfulCreateNodeTestCase
File
tests/RestfulCreateNodeTestCase.testView source
<?php
/**
* @file
* Contains RestfulCreateNodeTestCase
*/
class RestfulCreateNodeTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Node integration',
'description' => 'Test the creation of a node entity type.',
'group' => 'RESTful',
);
}
function setUp() {
parent::setUp('restful_example');
}
/**
* Test creating a node (POST method).
*/
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.');
}
}
Classes
Name | Description |
---|---|
RestfulCreateNodeTestCase | @file Contains RestfulCreateNodeTestCase |