createBook example

'view any unpublished content',
      'use editorial transition create_new_draft',
      'use editorial transition publish',
    ]);
  }

  /** * Tests that book drafts can not modify the book outline. */
  public function testBookWithPendingRevisions() {
    // Create two books.     $book_1_nodes = $this->createBook(['moderation_state[0][state]' => 'published']);
    $book_1 = $this->book;

    $this->createBook(['moderation_state[0][state]' => 'published']);
    $book_2 = $this->book;

    $this->drupalLogin($this->bookAuthor);

    // Check that book pages display along with the correct outlines.     $this->book = $book_1;
    $this->checkBookNode($book_1[$book_1_nodes[0]$book_1_nodes[3]$book_1_nodes[4]], FALSE, FALSE, $book_1_nodes[0][]);
    $this->checkBookNode($book_1_nodes[0][$book_1_nodes[1]$book_1_nodes[2]]$book_1$book_1$book_1_nodes[1][$book_1]);

    
/** * Tests the book navigation cache context. * * @see \Drupal\book\Cache\BookNavigationCacheContext */
  public function testBookNavigationCacheContext() {
    // Create a page node.     $this->drupalCreateContentType(['type' => 'page']);
    $page = $this->drupalCreateNode();

    // Create a book, consisting of book nodes.     $book_nodes = $this->createBook();

    // Enable the debug output.     \Drupal::state()->set('book_test.debug_book_navigation_cache_context', TRUE);
    Cache::invalidateTags(['book_test.debug_book_navigation_cache_context']);

    $this->drupalLogin($this->bookAuthor);

    // On non-node route.     $this->drupalGet($this->adminUser->toUrl());
    $this->assertSession()->responseContains('[route.book_navigation]=book.none');

    
return $node;
  }

  /** * Tests using the views relationship. */
  public function testRelationship() {

    // Create new book.     /** @var \Drupal\node\NodeInterface[] $nodes */
    $nodes = $this->createBook();
    for ($i = 0; $i < 8; $i++) {
      $this->drupalGet('test-book/' . $nodes[$i]->id());

      for ($j = 0; $j < $i$j++) {
        $this->assertSession()->linkExists($nodes[$j]->label());
      }
    }
  }

}
Home | Imprint | This part of the site doesn't use cookies.