Commit 52f2a292 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2795579 by martin107, klausi, dawehner: Adapt assertCacheContexts to...

Issue #2795579 by martin107, klausi, dawehner: Adapt assertCacheContexts to not rely on the return value of assertIdentical
parent e8885ed6
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -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;
  }

  /**