public function HeadersCacheContextTest::testGetContext in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Cache/Context/HeadersCacheContextTest.php \Drupal\Tests\Core\Cache\Context\HeadersCacheContextTest::testGetContext()
- 10 core/tests/Drupal/Tests/Core/Cache/Context/HeadersCacheContextTest.php \Drupal\Tests\Core\Cache\Context\HeadersCacheContextTest::testGetContext()
@covers ::getContext
@dataProvider providerTestGetContext
File
- core/
tests/ Drupal/ Tests/ Core/ Cache/ Context/ HeadersCacheContextTest.php, line 21
Class
- HeadersCacheContextTest
- @coversDefaultClass \Drupal\Core\Cache\Context\HeadersCacheContext @group Cache
Namespace
Drupal\Tests\Core\Cache\ContextCode
public function testGetContext($headers, $header_name, $context) {
$request_stack = new RequestStack();
$request = Request::create('/', 'GET');
// Request defaults could change, so compare with default values instead of
// passed in context value.
$request->headers
->replace($headers);
$request_stack
->push($request);
$cache_context = new HeadersCacheContext($request_stack);
$this
->assertSame($cache_context
->getContext($header_name), $context);
}