Skip to content
Snippets Groups Projects
Commit 47a7f18b authored by catch's avatar catch
Browse files

Issue #2784263 by klausi: Move WTB::assertCacheContext() to AssertPageCacheContextsAndTagsTrait

parent db998a72
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@
use Drupal\Core\StreamWrapper\PublicStream;
use Drupal\Core\Test\AssertMailTrait;
use Drupal\Core\Url;
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Yaml\Yaml as SymfonyYaml;
......@@ -38,6 +39,7 @@
abstract class WebTestBase extends TestBase {
use AssertContentTrait;
use AssertPageCacheContextsAndTagsTrait;
use BlockCreationTrait {
placeBlock as drupalPlaceBlock;
}
......@@ -2707,28 +2709,6 @@ protected function buildUrl($path, array $options = array()) {
}
}
/**
* Asserts whether an expected cache context was present in the last response.
*
* @param string $expected_cache_context
* The expected cache context.
*/
protected function assertCacheContext($expected_cache_context) {
$cache_contexts = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Contexts'));
$this->assertTrue(in_array($expected_cache_context, $cache_contexts), "'" . $expected_cache_context . "' is present in the X-Drupal-Cache-Contexts header.");
}
/**
* Asserts that a cache context was not present in the last response.
*
* @param string $not_expected_cache_context
* The expected cache context.
*/
protected function assertNoCacheContext($not_expected_cache_context) {
$cache_contexts = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Contexts'));
$this->assertFalse(in_array($not_expected_cache_context, $cache_contexts), "'" . $not_expected_cache_context . "' is not present in the X-Drupal-Cache-Contexts header.");
}
/**
* Asserts whether an expected cache tag was present in the last response.
*
......
......@@ -40,6 +40,28 @@ protected function getCacheHeaderValues($header_name) {
}
}
/**
* Asserts whether an expected cache context was present in the last response.
*
* @param string $expected_cache_context
* The expected cache context.
*/
protected function assertCacheContext($expected_cache_context) {
$cache_contexts = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Contexts'));
$this->assertTrue(in_array($expected_cache_context, $cache_contexts), "'" . $expected_cache_context . "' is present in the X-Drupal-Cache-Contexts header.");
}
/**
* Asserts that a cache context was not present in the last response.
*
* @param string $not_expected_cache_context
* The expected cache context.
*/
protected function assertNoCacheContext($not_expected_cache_context) {
$cache_contexts = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Contexts'));
$this->assertFalse(in_array($not_expected_cache_context, $cache_contexts), "'" . $not_expected_cache_context . "' is not present in the X-Drupal-Cache-Contexts header.");
}
/**
* Asserts page cache miss, then hit for the given URL; checks cache headers.
*
......
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