public function BookTest::testBookNavigationBlockOnUnpublishedBook in Drupal 10
Same name and namespace in other branches
- 8 core/modules/book/tests/src/Functional/BookTest.php \Drupal\Tests\book\Functional\BookTest::testBookNavigationBlockOnUnpublishedBook()
- 9 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 688
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
->drupalGet('node/' . $this->book
->id() . '/edit');
$this
->submitForm($edit, 'Save');
// Test node page.
$this
->drupalGet('node/' . $this->book
->id());
// Unpublished book with "Show block only on book pages" book navigation
// settings.
$this
->assertSession()
->pageTextContains($this->book
->label());
}