function BookRelationshipTest::createBook
Same name in other branches
- 9 core/modules/book/tests/src/Functional/Views/BookRelationshipTest.php \Drupal\Tests\book\Functional\Views\BookRelationshipTest::createBook()
- 8.9.x core/modules/book/tests/src/Functional/Views/BookRelationshipTest.php \Drupal\Tests\book\Functional\Views\BookRelationshipTest::createBook()
- 11.x core/modules/book/tests/src/Functional/Views/BookRelationshipTest.php \Drupal\Tests\book\Functional\Views\BookRelationshipTest::createBook()
Creates a new book with a page hierarchy.
1 call to BookRelationshipTest::createBook()
- BookRelationshipTest::testRelationship in core/
modules/ book/ tests/ src/ Functional/ Views/ BookRelationshipTest.php - Tests using the views relationship.
File
-
core/
modules/ book/ tests/ src/ Functional/ Views/ BookRelationshipTest.php, line 74
Class
- BookRelationshipTest
- Tests entity reference relationship data.
Namespace
Drupal\Tests\book\Functional\ViewsCode
protected function createBook() {
// Create new book.
$this->drupalLogin($this->bookAuthor);
$this->book = $this->createBookNode('new');
$book = $this->book;
$nodes = [];
// Node 0.
$nodes[] = $this->createBookNode($book->id());
// Node 1.
$nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['nid']);
// Node 2.
$nodes[] = $this->createBookNode($book->id(), $nodes[1]->book['nid']);
// Node 3.
$nodes[] = $this->createBookNode($book->id(), $nodes[2]->book['nid']);
// Node 4.
$nodes[] = $this->createBookNode($book->id(), $nodes[3]->book['nid']);
// Node 5.
$nodes[] = $this->createBookNode($book->id(), $nodes[4]->book['nid']);
// Node 6.
$nodes[] = $this->createBookNode($book->id(), $nodes[5]->book['nid']);
// Node 7.
$nodes[] = $this->createBookNode($book->id(), $nodes[6]->book['nid']);
$this->drupalLogout();
return $nodes;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.