function BookTest::testNavigationBlockOnAccessModuleInstalled
Same name in other branches
- 9 core/modules/book/tests/src/Functional/BookTest.php \Drupal\Tests\book\Functional\BookTest::testNavigationBlockOnAccessModuleInstalled()
- 10 core/modules/book/tests/src/Functional/BookTest.php \Drupal\Tests\book\Functional\BookTest::testNavigationBlockOnAccessModuleInstalled()
- 11.x core/modules/book/tests/src/Functional/BookTest.php \Drupal\Tests\book\Functional\BookTest::testNavigationBlockOnAccessModuleInstalled()
Tests the book navigation block when an access module is installed.
File
-
core/
modules/ book/ tests/ src/ Functional/ BookTest.php, line 347
Class
- BookTest
- Create a book, add pages, and test book interface.
Namespace
Drupal\Tests\book\FunctionalCode
public function testNavigationBlockOnAccessModuleInstalled() {
$this->drupalLogin($this->adminUser);
$block = $this->drupalPlaceBlock('book_navigation', [
'block_mode' => 'book pages',
]);
// Give anonymous users the permission 'node test view'.
$edit = [];
$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.");
// Create a book.
$this->createBook();
// Test correct display of the block to registered users.
$this->drupalLogin($this->webUser);
$this->drupalGet('node/' . $this->book
->id());
$this->assertText($block->label(), 'Book navigation block is displayed to registered users.');
$this->drupalLogout();
// Test correct display of the block to anonymous users.
$this->drupalGet('node/' . $this->book
->id());
$this->assertText($block->label(), 'Book navigation block is displayed to anonymous users.');
// Test the 'book pages' block_mode setting.
$this->drupalGet('<front>');
$this->assertNoText($block->label(), 'Book navigation block is not shown on non-book pages.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.