function BookBreadcrumbTest::createBreadcrumbBook

Same name in other branches
  1. 8.9.x core/modules/book/tests/src/Functional/BookBreadcrumbTest.php \Drupal\Tests\book\Functional\BookBreadcrumbTest::createBreadcrumbBook()
  2. 10 core/modules/book/tests/src/Functional/BookBreadcrumbTest.php \Drupal\Tests\book\Functional\BookBreadcrumbTest::createBreadcrumbBook()
  3. 11.x 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
Tests that the breadcrumb is updated when book access changes.
BookBreadcrumbTest::testBreadcrumbTitleUpdates in core/modules/book/tests/src/Functional/BookBreadcrumbTest.php
Tests that the breadcrumb is updated when book content changes.

File

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

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.