You are here

function BookTest::testBookNavigationBlock in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/book/src/Tests/BookTest.php \Drupal\book\Tests\BookTest::testBookNavigationBlock()

Tests the functionality of the book navigation block.

File

core/modules/book/src/Tests/BookTest.php, line 421
Contains \Drupal\book\Tests\BookTest.

Class

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

Namespace

Drupal\book\Tests

Code

function testBookNavigationBlock() {
  $this
    ->drupalLogin($this->adminUser);

  // Enable the block.
  $block = $this
    ->drupalPlaceBlock('book_navigation');

  // Give anonymous users the permission 'node test view'.
  $edit = array();
  $edit[RoleInterface::ANONYMOUS_ID . '[node test view]'] = TRUE;
  $this
    ->drupalPostForm('admin/people/permissions/' . RoleInterface::ANONYMOUS_ID, $edit, t('Save permissions'));
  $this
    ->assertText(t('The changes have been saved.'), "Permission 'node test view' successfully assigned to anonymous users.");

  // Test correct display of the block.
  $nodes = $this
    ->createBook();
  $this
    ->drupalGet('<front>');
  $this
    ->assertText($block
    ->label(), 'Book navigation block is displayed.');
  $this
    ->assertText($this->book
    ->label(), format_string('Link to book root (@title) is displayed.', array(
    '@title' => $nodes[0]
      ->label(),
  )));
  $this
    ->assertNoText($nodes[0]
    ->label(), 'No links to individual book pages are displayed.');
}