function BookTestTrait::createBook
Same name in other branches
- 9 core/modules/book/tests/src/Functional/BookTestTrait.php \Drupal\Tests\book\Functional\BookTestTrait::createBook()
- 10 core/modules/book/tests/src/Functional/BookTestTrait.php \Drupal\Tests\book\Functional\BookTestTrait::createBook()
- 11.x core/modules/book/tests/src/Functional/BookTestTrait.php \Drupal\Tests\book\Functional\BookTestTrait::createBook()
Creates a new book with a page hierarchy.
Parameters
array $edit: (optional) Field data in an associative array. Changes the current input fields (where possible) to the values indicated. Defaults to an empty array.
Return value
12 calls to BookTestTrait::createBook()
- BookContentModerationTest::testBookWithPendingRevisions in core/
modules/ book/ tests/ src/ Functional/ BookContentModerationTest.php - Tests that book drafts can not modify the book outline.
- BookTest::testAdminBookListing in core/
modules/ book/ tests/ src/ Functional/ BookTest.php - Tests the administrative listing of all books.
- BookTest::testAdminBookNodeListing in core/
modules/ book/ tests/ src/ Functional/ BookTest.php - Tests the administrative listing of all book pages in a book.
- BookTest::testBook in core/
modules/ book/ tests/ src/ Functional/ BookTest.php - Tests book functionality through node interfaces.
- BookTest::testBookDelete in core/
modules/ book/ tests/ src/ Functional/ BookTest.php - Tests the access for deleting top-level book nodes.
File
-
core/
modules/ book/ tests/ src/ Functional/ BookTestTrait.php, line 39
Class
- BookTestTrait
- Provides common functionality for Book test classes.
Namespace
Drupal\Tests\book\FunctionalCode
public function createBook($edit = []) {
// Create new book.
$this->drupalLogin($this->bookAuthor);
$this->book = $this->createBookNode('new', NULL, $edit);
$book = $this->book;
/*
* Add page hierarchy to book.
* Book
* |- Node 0
* |- Node 1
* |- Node 2
* |- Node 3
* |- Node 4
*/
$nodes = [];
// Node 0.
$nodes[] = $this->createBookNode($book->id(), NULL, $edit);
// Node 1.
$nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['nid'], $edit);
// Node 2.
$nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['nid'], $edit);
// Node 3.
$nodes[] = $this->createBookNode($book->id(), NULL, $edit);
// Node 4.
$nodes[] = $this->createBookNode($book->id(), NULL, $edit);
$this->drupalLogout();
return $nodes;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.