Skip to content
Snippets Groups Projects
Commit 199ef1a1 authored by catch's avatar catch
Browse files

Issue #2978261 by Berdir, msankhala, Wim Leers, roderik:...

Issue #2978261 by Berdir, msankhala, Wim Leers, roderik: \Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait::assertCacheContexts() is unhelpful after conversion to phpunit
parent 442a3f22
No related branches found
No related tags found
No related merge requests found
......@@ -94,22 +94,6 @@ protected function assertPageCacheContextsAndTags(Url $url, array $expected_cont
$cache_entry = \Drupal::cache('page')->get($cid);
sort($cache_entry->tags);
$this->assertEqual($cache_entry->tags, $expected_tags);
$this->debugCacheTags($cache_entry->tags, $expected_tags);
}
/**
* Provides debug information for cache tags.
*
* @param string[] $actual_tags
* The actual cache tags.
* @param string[] $expected_tags
* The expected cache tags.
*/
protected function debugCacheTags(array $actual_tags, array $expected_tags) {
if ($actual_tags !== $expected_tags) {
debug('Unwanted cache tags in response: ' . implode(',', array_diff($actual_tags, $expected_tags)));
debug('Missing cache tags in response: ' . implode(',', array_diff($expected_tags, $actual_tags)));
}
}
/**
......@@ -133,7 +117,6 @@ protected function assertCacheTags(array $expected_tags, $include_default_tags =
sort($expected_tags);
sort($actual_tags);
$this->assertIdentical($actual_tags, $expected_tags);
$this->debugCacheTags($actual_tags, $expected_tags);
}
/**
......@@ -163,17 +146,8 @@ protected function assertCacheContexts(array $expected_contexts, $message = NULL
$actual_contexts = $this->getCacheHeaderValues('X-Drupal-Cache-Contexts');
sort($expected_contexts);
sort($actual_contexts);
$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)));
}
$this->assertIdentical($actual_contexts, $expected_contexts, $message);
// For compatibility with both BrowserTestBase and WebTestBase always return
// a boolean.
return $match;
return $actual_contexts === $expected_contexts;
}
/**
......@@ -183,10 +157,7 @@ protected function assertCacheContexts(array $expected_contexts, $message = NULL
*/
protected function assertCacheMaxAge($max_age) {
$cache_control_header = $this->drupalGetHeader('Cache-Control');
if (strpos($cache_control_header, 'max-age:' . $max_age) === FALSE) {
debug('Expected max-age:' . $max_age . '; Response max-age:' . $cache_control_header);
}
$this->assertTrue(strpos($cache_control_header, 'max-age:' . $max_age));
$this->assertContains('max-age:' . $max_age, $cache_control_header);
}
}
......@@ -54,7 +54,6 @@ protected function assertViewsCacheTags(ViewExecutable $view, $expected_results_
$this->pass('Checking render array cache tags.');
sort($expected_render_array_cache_tags);
$this->assertEqual($build['#cache']['tags'], $expected_render_array_cache_tags);
$this->debugCacheTags($build['#cache']['tags'], $expected_render_array_cache_tags);
if ($views_caching_is_enabled) {
$this->pass('Checking Views results cache item cache tags.');
......@@ -71,7 +70,6 @@ protected function assertViewsCacheTags(ViewExecutable $view, $expected_results_
if ($results_cache_item) {
sort($expected_results_cache);
$this->assertEqual($results_cache_item->tags, $expected_results_cache);
$this->debugCacheTags($results_cache_item->tags, $expected_results_cache);
}
}
else {
......@@ -88,7 +86,6 @@ protected function assertViewsCacheTags(ViewExecutable $view, $expected_results_
$this->assertTrue(!empty($render_cache_item), 'Render cache item found.');
if ($render_cache_item) {
$this->assertEqual($render_cache_item['#cache']['tags'], $expected_render_array_cache_tags);
$this->debugCacheTags($render_cache_item['#cache']['tags'], $expected_render_array_cache_tags);
}
}
else {
......@@ -139,7 +136,6 @@ protected function assertViewsCacheTagsFromStaticRenderArray(ViewExecutable $vie
$this->pass('Checking render array cache tags.');
sort($expected_render_array_cache_tags);
$this->assertEqual($build['#cache']['tags'], $expected_render_array_cache_tags);
$this->debugCacheTags($build['#cache']['tags'], $expected_render_array_cache_tags);
$this->pass('Checking Views render cache item cache tags.');
$original['#cache'] += ['contexts' => []];
......@@ -150,7 +146,6 @@ protected function assertViewsCacheTagsFromStaticRenderArray(ViewExecutable $vie
$this->assertTrue(!empty($render_cache_item), 'Render cache item found.');
if ($render_cache_item) {
$this->assertEqual($render_cache_item['#cache']['tags'], $expected_render_array_cache_tags);
$this->debugCacheTags($render_cache_item['#cache']['tags'], $expected_render_array_cache_tags);
}
}
else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment