You are here

protected function BookRelationshipTest::createBook in Drupal 8

Same name and namespace in other branches
  1. 9 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 71

Class

BookRelationshipTest
Tests entity reference relationship data.

Namespace

Drupal\Tests\book\Functional\Views

Code

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