From 52f2a29268a7a98622e3048aeb6ed35d68ee6afe Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Thu, 22 Sep 2016 15:06:01 +0100
Subject: [PATCH] Issue #2795579 by martin107, klausi, dawehner: Adapt
 assertCacheContexts to not rely on the return value of assertIdentical

---
 .../Cache/AssertPageCacheContextsAndTagsTrait.php   | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php b/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php
index e7fd9cdd7fc7..94ea1ac44c5b 100644
--- a/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php
+++ b/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php
@@ -142,7 +142,7 @@ protected function assertCacheTags(array $expected_tags, $include_default_tags =
    * @param bool $include_default_contexts
    *   (optional) Whether the default contexts should automatically be included.
    *
-   * @return
+   * @return bool
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertCacheContexts(array $expected_contexts, $message = NULL, $include_default_contexts = TRUE) {
@@ -159,12 +159,17 @@ protected function assertCacheContexts(array $expected_contexts, $message = NULL
     $actual_contexts = $this->getCacheHeaderValues('X-Drupal-Cache-Contexts');
     sort($expected_contexts);
     sort($actual_contexts);
-    $return = $this->assertIdentical($actual_contexts, $expected_contexts, $message);
-    if (!$return) {
+    $match = $actual_contexts === $expected_contexts;
+    if (!$match) {
       debug('Unwanted cache contexts in response: ' . implode(',', array_diff($actual_contexts, $expected_contexts)));
       debug('Missing cache contexts in response: ' . implode(',', array_diff($expected_contexts, $actual_contexts)));
     }
-    return $return;
+
+    $this->assertIdentical($actual_contexts, $expected_contexts, $message);
+
+    // For compatibility with both BrowserTestBase and WebTestBase always return
+    // a boolean.
+    return $match;
   }
 
   /**
-- 
GitLab