function BookModuleTestCase::createBookNode in SimpleTest 6
Create book node.
Parameters
integer $book_nid Book node id or set to 'new' to create new book.:
integer $parent Parent book reference id.:
1 call to BookModuleTestCase::createBookNode()
- BookModuleTestCase::testBook in tests/
book_module.test - Test book funcitonality through node interfaces.
File
- tests/
book_module.test, line 118
Class
Code
function createBookNode($book_nid, $parent = NULL) {
static $number = 0;
// used to ensure that when sorted nodes stay in same order
$this
->drupalVariableSet('node_options_page', array(
'status',
'promote',
));
$edit = array();
$edit['title'] = $number . ' - SimpleTest test node ' . $this
->randomName(10);
$edit['body'] = 'SimpleTest test body ' . $this
->randomName(32) . ' ' . $this
->randomName(32);
$edit['book[bid]'] = $book_nid;
if ($parent !== NULL) {
$this
->drupalPost('node/add/book', $edit, 'Change book (update list of parents)');
$edit['book[plid]'] = $parent;
$this
->drupalPost(NULL, $edit, 'Save');
}
else {
$this
->drupalPost('node/add/book', $edit, 'Save');
}
// check to make sure the book node was created
$node = node_load(array(
'title' => $edit['title'],
));
$this
->assertNotNull($node === FALSE ? NULL : $node, 'Book node found in database.');
$number++;
return $node;
}