function BookTest::createBook in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/book/src/Tests/BookTest.php \Drupal\book\Tests\BookTest::createBook()
Creates a new book with a page hierarchy.
10 calls to BookTest::createBook()
- BookTest::testAdminBookListing in core/
modules/ book/ src/ Tests/ BookTest.php - Tests the administrative listing of all books.
- BookTest::testAdminBookNodeListing in core/
modules/ book/ src/ Tests/ BookTest.php - Tests the administrative listing of all book pages in a book.
- BookTest::testBook in core/
modules/ book/ src/ Tests/ BookTest.php - Tests book functionality through node interfaces.
- BookTest::testBookDelete in core/
modules/ book/ src/ Tests/ BookTest.php - Tests the access for deleting top-level book nodes.
- BookTest::testBookExport in core/
modules/ book/ src/ Tests/ BookTest.php - Tests book export ("printer-friendly version") functionality.
File
- core/
modules/ book/ src/ Tests/ BookTest.php, line 86 - Contains \Drupal\book\Tests\BookTest.
Class
- BookTest
- Create a book, add pages, and test book interface.
Namespace
Drupal\book\TestsCode
function createBook() {
// Create new book.
$this
->drupalLogin($this->bookAuthor);
$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
->id());
// Node 0.
$nodes[] = $this
->createBookNode($book
->id(), $nodes[0]->book['nid']);
// Node 1.
$nodes[] = $this
->createBookNode($book
->id(), $nodes[0]->book['nid']);
// Node 2.
$nodes[] = $this
->createBookNode($book
->id());
// Node 3.
$nodes[] = $this
->createBookNode($book
->id());
// Node 4.
$this
->drupalLogout();
return $nodes;
}