public function BookTest::testNavigationBlockOnAccessModuleInstalled in Drupal 8
Same name and namespace 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()
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.');
}