diff -u b/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php --- b/core/modules/book/tests/src/Functional/BookTest.php +++ b/core/modules/book/tests/src/Functional/BookTest.php @@ -22,6 +22,7 @@ * @var array */ protected static $modules = [ + 'content_moderation', 'book', 'block', 'node_access_test', @@ -71,6 +72,7 @@ 'create book content', 'edit own book content', 'add content to books', + 'view own unpublished content', ]); $this->webUser = $this->drupalCreateUser([ 'access printer-friendly version', @@ -91,6 +93,7 @@ 'node test view', 'administer content types', 'administer site configuration', + 'view any unpublished content', ]); } @@ -561,6 +564,21 @@ $this->drupalGet('book'); $this->assertSession()->responseContains($this->book->label()); + + // Unpublish the top book page and confirm that the created book title is + // displayed for people who has 'view own unpublished content' permission. + $this->drupalLogin($this->bookAuthor); + $this->book->setUnpublished(); + $this->book->save(); + + $this->drupalGet('book'); + $this->assertSession()->responseContains($this->book->label()); + + // Confirm that the created book title is displayed for + // people who has 'view any unpublished content' permission. + $this->drupalLogin($this->adminUser); + $this->drupalGet('book'); + $this->assertSession()->responseContains($this->book->label()); } /**