public function BookTest::testBookNavigationBlockOnUnpublishedBook in Drupal 8
Same name and namespace in other branches
- 9 core/modules/book/tests/src/Functional/BookTest.php \Drupal\Tests\book\Functional\BookTest::testBookNavigationBlockOnUnpublishedBook()
- 10 core/modules/book/tests/src/Functional/BookTest.php \Drupal\Tests\book\Functional\BookTest::testBookNavigationBlockOnUnpublishedBook()
Tests the book navigation block when book is unpublished.
There was a fatal error with "Show block only on book pages" block mode.
File
- core/
modules/ book/ tests/ src/ Functional/ BookTest.php, line 623
Class
- BookTest
- Create a book, add pages, and test book interface.
Namespace
Drupal\Tests\book\FunctionalCode
public function testBookNavigationBlockOnUnpublishedBook() {
// Create a new book.
$this
->createBook();
// Create administrator user.
$administratorUser = $this
->drupalCreateUser([
'administer blocks',
'administer nodes',
'bypass node access',
]);
$this
->drupalLogin($administratorUser);
// Enable the block with "Show block only on book pages" mode.
$this
->drupalPlaceBlock('book_navigation', [
'block_mode' => 'book pages',
]);
// Unpublish book node.
$edit = [
'status[value]' => FALSE,
];
$this
->drupalPostForm('node/' . $this->book
->id() . '/edit', $edit, t('Save'));
// Test node page.
$this
->drupalGet('node/' . $this->book
->id());
$this
->assertText($this->book
->label(), 'Unpublished book with "Show block only on book pages" book navigation settings.');
}