core/modules/book/src/Tests/BookTest.php | 30 +++++++++++++----------- core/modules/book/tests/modules/book_test.module | 1 + 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/core/modules/book/src/Tests/BookTest.php b/core/modules/book/src/Tests/BookTest.php index 950b9dc..d2394cd 100644 --- a/core/modules/book/src/Tests/BookTest.php +++ b/core/modules/book/src/Tests/BookTest.php @@ -8,6 +8,7 @@ namespace Drupal\book\Tests; use Drupal\Component\Utility\SafeMarkup; +use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\EntityInterface; use Drupal\simpletest\WebTestBase; use Drupal\user\RoleInterface; @@ -125,6 +126,7 @@ public function testBookNavigationCacheContext() { // Enable the debug output. \Drupal::state()->set('book_test.debug_book_navigation_cache_context', TRUE); + Cache::invalidateTags(['book_test.debug_book_navigation_cache_context']); $this->drupalLogin($this->bookAuthor); @@ -152,7 +154,7 @@ public function testBookNavigationCacheContext() { /** * Tests saving the book outline on an empty book. */ - function atestEmptyBook() { + function testEmptyBook() { // Create a new empty book. $this->drupalLogin($this->bookAuthor); $book = $this->createBookNode('new'); @@ -167,7 +169,7 @@ function atestEmptyBook() { /** * Tests book functionality through node interfaces. */ - function atestBook() { + function testBook() { // Create new book. $nodes = $this->createBook(); $book = $this->book; @@ -371,7 +373,7 @@ function createBookNode($book_nid, $parent = NULL) { /** * Tests book export ("printer-friendly version") functionality. */ - function atestBookExport() { + function testBookExport() { // Create a book. $nodes = $this->createBook(); @@ -416,7 +418,7 @@ function atestBookExport() { /** * Tests the functionality of the book navigation block. */ - function atestBookNavigationBlock() { + function testBookNavigationBlock() { $this->drupalLogin($this->adminUser); // Enable the block. @@ -439,7 +441,7 @@ function atestBookNavigationBlock() { /** * Tests the book navigation block when an access module is installed. */ - function atestNavigationBlockOnAccessModuleInstalled() { + function testNavigationBlockOnAccessModuleInstalled() { $this->drupalLogin($this->adminUser); $block = $this->drupalPlaceBlock('book_navigation', array('block_mode' => 'book pages')); @@ -470,7 +472,7 @@ function atestNavigationBlockOnAccessModuleInstalled() { /** * Tests the access for deleting top-level book nodes. */ - function atestBookDelete() { + function testBookDelete() { $node_storage = $this->container->get('entity.manager')->getStorage('node'); $nodes = $this->createBook(); $this->drupalLogin($this->adminUser); @@ -498,7 +500,7 @@ function atestBookDelete() { /* * Tests node type changing machine name when type is a book allowed type. */ - function atestBookNodeTypeChange() { + function testBookNodeTypeChange() { $this->drupalLogin($this->adminUser); // Change the name, machine name and description. $edit = array( @@ -591,7 +593,7 @@ function atestBookNodeTypeChange() { /** * Tests re-ordering of books. */ - public function atestBookOrdering() { + public function testBookOrdering() { // Create new book. $this->createBook(); $book = $this->book; @@ -619,7 +621,7 @@ public function atestBookOrdering() { /** * Tests outline of a book. */ - public function atestBookOutline() { + public function testBookOutline() { $this->drupalLogin($this->bookAuthor); // Create new node not yet a book. @@ -673,7 +675,7 @@ public function atestBookOutline() { /** * Tests that saveBookLink() returns something. */ - public function atestSaveBookLink() { + public function testSaveBookLink() { $book_manager = \Drupal::service('book.manager'); // Mock a link for a new book. @@ -693,7 +695,7 @@ public function atestSaveBookLink() { /** * Tests the listing of all books. */ - public function atestBookListing() { + public function testBookListing() { // Create a new book. $this->createBook(); @@ -709,7 +711,7 @@ public function atestBookListing() { /** * Tests the administrative listing of all books. */ - public function atestAdminBookListing() { + public function testAdminBookListing() { // Create a new book. $this->createBook(); @@ -722,7 +724,7 @@ public function atestAdminBookListing() { /** * Tests the administrative listing of all book pages in a book. */ - public function atestAdminBookNodeListing() { + public function testAdminBookNodeListing() { // Create a new book. $this->createBook(); $this->drupalLogin($this->adminUser); @@ -739,7 +741,7 @@ public function atestAdminBookNodeListing() { /** * Ensure the loaded book in hook_node_load() does not depend on the user. */ - public function atestHookNodeLoadAccess() { + public function testHookNodeLoadAccess() { \Drupal::service('module_installer')->install(['node_access_test']); // Ensure that the loaded book in hook_node_load() does NOT depend on the diff --git a/core/modules/book/tests/modules/book_test.module b/core/modules/book/tests/modules/book_test.module index 2f868a4..939e756 100644 --- a/core/modules/book/tests/modules/book_test.module +++ b/core/modules/book/tests/modules/book_test.module @@ -15,6 +15,7 @@ * Implements hook_page_attachments(). */ function book_test_page_attachments(array &$page) { + $page['#cache']['tags'][] = 'book_test.debug_book_navigation_cache_context'; if (\Drupal::state()->get('book_test.debug_book_navigation_cache_context', FALSE)) { drupal_set_message(\Drupal::service('cache_contexts_manager')->convertTokensToKeys(['route.book_navigation'])->getKeys()[0]); }