You are here

protected function BookBreadcrumbTest::createBreadcrumbBook in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/book/tests/src/Functional/BookBreadcrumbTest.php \Drupal\Tests\book\Functional\BookBreadcrumbTest::createBreadcrumbBook()

Creates a new book with a page hierarchy.

Return value

\Drupal\node\NodeInterface[] The created book nodes.

2 calls to BookBreadcrumbTest::createBreadcrumbBook()
BookBreadcrumbTest::testBreadcrumbAccessUpdates in core/modules/book/tests/src/Functional/BookBreadcrumbTest.php
Test that the breadcrumb is updated when book access changes.
BookBreadcrumbTest::testBreadcrumbTitleUpdates in core/modules/book/tests/src/Functional/BookBreadcrumbTest.php
Test that the breadcrumb is updated when book content changes.

File

core/modules/book/tests/src/Functional/BookBreadcrumbTest.php, line 82

Class

BookBreadcrumbTest
Create a book, add pages, and test book interface.

Namespace

Drupal\Tests\book\Functional

Code

protected function createBreadcrumbBook() {

  // 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
   *      |- Node 5
   *  |- Node 6
   */
  $nodes = [];
  $nodes[0] = $this
    ->createBookNode($book
    ->id());
  $nodes[1] = $this
    ->createBookNode($book
    ->id(), $nodes[0]
    ->id());
  $nodes[2] = $this
    ->createBookNode($book
    ->id(), $nodes[0]
    ->id());
  $nodes[3] = $this
    ->createBookNode($book
    ->id(), $nodes[2]
    ->id());
  $nodes[4] = $this
    ->createBookNode($book
    ->id(), $nodes[3]
    ->id());
  $nodes[5] = $this
    ->createBookNode($book
    ->id(), $nodes[4]
    ->id());
  $nodes[6] = $this
    ->createBookNode($book
    ->id());
  $this
    ->drupalLogout();
  return $nodes;
}