function ExceptionStatusCodeCacheContextTest::testGetContext
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Cache/Context/ExceptionStatusCodeCacheContextTest.php \Drupal\Tests\Core\Cache\Context\ExceptionStatusCodeCacheContextTest::testGetContext()
Tests get context.
Attributes
#[DataProvider('providerTestGetContext')]
File
-
core/
tests/ Drupal/ Tests/ Core/ Cache/ Context/ ExceptionStatusCodeCacheContextTest.php, line 29
Class
Namespace
Drupal\Tests\Core\Cache\ContextCode
public function testGetContext(?\Exception $exception, string $result) : void {
$request_stack = new RequestStack();
$request = Request::create('/', 'GET');
if (isset($exception)) {
$request->attributes
->set('exception', $exception);
}
$request_stack->push($request);
$cache_context = new ExceptionStatusCodeCacheContext($request_stack);
$this->assertSame($cache_context->getContext(), $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.