function BookTestCase::createBook in Drupal 7
Creates a new book with a page hierarchy.
5 calls to BookTestCase::createBook()
- BookTestCase::testBook in modules/
book/ book.test - Tests book functionality through node interfaces.
- BookTestCase::testBookDelete in modules/
book/ book.test - Tests the access for deleting top-level book nodes.
- BookTestCase::testBookExport in modules/
book/ book.test - Tests book export ("printer-friendly version") functionality.
- BookTestCase::testBookNavigationBlock in modules/
book/ book.test - Tests the functionality of the book navigation block.
- BookTestCase::testNavigationBlockOnAccessModuleEnabled in modules/
book/ book.test - Tests the book navigation block when an access module is enabled.
File
- modules/
book/ book.test, line 64 - Tests for book.module.
Class
- BookTestCase
- Tests the functionality of the Book module.
Code
function createBook() {
// Create new book.
$this
->drupalLogin($this->book_author);
$this->book = $this
->createBookNode('new');
$book = $this->book;
/*
* Add page hierarchy to book.
* Book
* |- Node 0
* |- Node 1
* |- Node 2
* |- Node 3
* |- Node 4
*/
$nodes = array();
$nodes[] = $this
->createBookNode($book->nid);
// Node 0.
$nodes[] = $this
->createBookNode($book->nid, $nodes[0]->book['mlid']);
// Node 1.
$nodes[] = $this
->createBookNode($book->nid, $nodes[0]->book['mlid']);
// Node 2.
$nodes[] = $this
->createBookNode($book->nid);
// Node 3.
$nodes[] = $this
->createBookNode($book->nid);
// Node 4.
$this
->drupalLogout();
return $nodes;
}