diff -u b/core/modules/toolbar/src/Tests/ToolbarCacheContextsTest.php b/core/modules/toolbar/src/Tests/ToolbarCacheContextsTest.php --- b/core/modules/toolbar/src/Tests/ToolbarCacheContextsTest.php +++ b/core/modules/toolbar/src/Tests/ToolbarCacheContextsTest.php @@ -68,29 +68,29 @@ */ public function testToolbarCacheContextsCaller() { // Test with default combination and permission to see toolbar. - $this->testToolbarCacheContexts(['user']); + $this->testToolbarCacheContexts(['user'], 'Expected cache contexts found for default combination and permission to see toolbar.'); // Test without user toolbar tab. User module is a required module so we have to // manually remove the user toolbar tab. \Drupal::service('module_installer')->install(['toolbar_disable_user_toolbar']); - $this->testToolbarCacheContexts(['user.permissions']); + $this->testToolbarCacheContexts(['user.permissions'], 'Expected cache contexts found without user toolbar tab.'); // Test with the toolbar and contextual enabled. \Drupal::service('module_installer')->install(['contextual']); $this->adminUser2 = $this->drupalCreateUser(array_merge($this->perms, ['access contextual links'])); - $this->testToolbarCacheContexts(['user.permissions']); + $this->testToolbarCacheContexts(['user.permissions'], 'Expected cache contexts found with contextual module enabled.'); \Drupal::service('module_installer')->uninstall(['contextual']); // Test with the tour module enabled. \Drupal::service('module_installer')->install(['tour']); $this->adminUser2 = $this->drupalCreateUser(array_merge($this->perms, ['access tour'])); - $this->testToolbarCacheContexts(['user.permissions']); + $this->testToolbarCacheContexts(['user.permissions'], 'Expected cache contexts found with tour module enabled.'); \Drupal::service('module_installer')->uninstall(['tour']); // Test with shortcut module enabled. \Drupal::service('module_installer')->install(['shortcut']); $this->adminUser2 = $this->drupalCreateUser(array_merge($this->perms, ['access shortcuts', 'administer shortcuts'])); - $this->testToolbarCacheContexts(['user']); + $this->testToolbarCacheContexts(['user'], 'Expected cache contexts found with shortcut module enabled.'); } /** @@ -98,8 +98,10 @@ * * @param string[] $cache_contexts * Expected cache contexts for both users. + * @param string $message + * (optional) A verbose message to output. */ - private function testToolbarCacheContexts(array $cache_contexts) { + private function testToolbarCacheContexts(array $cache_contexts, $message = NULL) { // Caches have to be rebuilt since modules might have added some routes. drupal_flush_all_caches(); @@ -113,13 +115,13 @@ // Assert contexts for user1 which has only default permissions. $this->drupalLogin($this->adminUser); $this->drupalGet('test-page'); - $this->assertCacheContexts($cache_contexts); + $this->assertCacheContexts($cache_contexts, $message); $this->drupalLogout(); // Assert contexts for user2 which has some additional permissions. $this->drupalLogin($this->adminUser2); $this->drupalGet('test-page'); - $this->assertCacheContexts($cache_contexts); + $this->assertCacheContexts($cache_contexts, $message); } } diff -u b/core/modules/toolbar/tests/modules/toolbar_disable_user_toolbar/toolbar_disable_user_toolbar.info.yml b/core/modules/toolbar/tests/modules/toolbar_disable_user_toolbar/toolbar_disable_user_toolbar.info.yml --- b/core/modules/toolbar/tests/modules/toolbar_disable_user_toolbar/toolbar_disable_user_toolbar.info.yml +++ b/core/modules/toolbar/tests/modules/toolbar_disable_user_toolbar/toolbar_disable_user_toolbar.info.yml @@ -1,4 +1,4 @@ -name: 'Disbale user toolbar' +name: 'Disable user toolbar' type: module description: 'Support module for testing toolbar without user toolbar' package: Testing only in patch2: unchanged: --- a/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php +++ b/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php @@ -102,12 +102,14 @@ protected function assertCacheTags(array $expected_tags) { * * @param string[] $expected_contexts * The expected cache contexts. + * @param string $message + * (optional) A verbose message to output. */ - protected function assertCacheContexts(array $expected_contexts) { + protected function assertCacheContexts(array $expected_contexts, $message = NULL) { $actual_contexts = $this->getCacheHeaderValues('X-Drupal-Cache-Contexts'); sort($expected_contexts); sort($actual_contexts); - $this->assertIdentical($actual_contexts, $expected_contexts); + $this->assertIdentical($actual_contexts, $expected_contexts, $message); if ($actual_contexts !== $expected_contexts) { debug('Missing cache contexts: ' . implode(',', array_diff($actual_contexts, $expected_contexts))); debug('Unwanted cache contexts: ' . implode(',', array_diff($expected_contexts, $actual_contexts)));