function SessionCacheContextTest::testSameContextForSameSession
Same name and namespace in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Cache/Context/SessionCacheContextTest.php \Drupal\Tests\Core\Cache\Context\SessionCacheContextTest::testSameContextForSameSession()
- 10 core/tests/Drupal/Tests/Core/Cache/Context/SessionCacheContextTest.php \Drupal\Tests\Core\Cache\Context\SessionCacheContextTest::testSameContextForSameSession()
- 11.x core/tests/Drupal/Tests/Core/Cache/Context/SessionCacheContextTest.php \Drupal\Tests\Core\Cache\Context\SessionCacheContextTest::testSameContextForSameSession()
@covers ::getContext
File
-
core/
tests/ Drupal/ Tests/ Core/ Cache/ Context/ SessionCacheContextTest.php, line 53
Class
- SessionCacheContextTest
- @coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Cache%21Context%21SessionCacheContext.php/class/SessionCacheContext/9" title="Defines the SessionCacheContext service, for "per session" caching." class="local">\Drupal\Core\Cache\Context\SessionCacheContext</a> @group Cache
Namespace
Drupal\Tests\Core\Cache\ContextCode
public function testSameContextForSameSession() {
$this->request
->setSession($this->session);
$cache_context = new SessionCacheContext($this->requestStack);
$session_id = 'aSebeZ52bbM6SvADurQP89SFnEpxY6j8';
$this->session
->expects($this->exactly(2))
->method('getId')
->willReturn($session_id);
$context1 = $cache_context->getContext();
$context2 = $cache_context->getContext();
$this->assertSame($context1, $context2);
$this->assertStringNotContainsString($session_id, $context1, 'Session ID not contained in cache context');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.