diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php index 67d8195d5f..6229264642 100644 --- a/core/modules/book/tests/src/Functional/BookTest.php +++ b/core/modules/book/tests/src/Functional/BookTest.php @@ -511,16 +511,23 @@ public function testBookListing() { $this->assertText($this->book->label(), 'The book title is displayed on the book listing page.'); - // Unpublish all the book nodes and Confirm that the created book title - // is not displayed for anonymous. + // Unpublish the top book page and confirm that the created book title is + // not displayed for anonymous. $this->book->setUnpublished(); $this->book->save(); - foreach ($nodes as $node) { - $node->setUnpublished(); - $node->save(); - } + $this->drupalGet('book'); $this->assertSession()->responseNotContains($this->book->label()); + + // Publish the top book page and unpublish a page in the book and confirm + // that the created book title is displayed for anonymous. + $this->book->setPublished(); + $this->book->save(); + $nodes[0]->setUnpublished(); + $nodes[0]->save(); + + $this->drupalGet('book'); + $this->assertSession()->responseContains($this->book->label()); } /**