3 namespace Drupal\Tests\Core\Cache\Context;
5 use Drupal\Core\Cache\Context\PathParentCacheContext;
6 use Drupal\Tests\UnitTestCase;
7 use Symfony\Component\HttpFoundation\Request;
8 use Symfony\Component\HttpFoundation\RequestStack;
11 * @coversDefaultClass \Drupal\Core\Cache\Context\PathParentCacheContext
14 class PathParentCacheContextTest extends UnitTestCase {
17 * @covers ::getContext
19 * @dataProvider providerTestGetContext
21 public function testGetContext($original_path, $context) {
22 $request_stack = new RequestStack();
23 $request = Request::create($original_path);
24 $request_stack->push($request);
25 $cache_context = new PathParentCacheContext($request_stack);
26 $this->assertSame($cache_context->getContext(), $context);
30 * Provides a list of paths and expected cache contexts.
32 public function providerTestGetContext() {
34 ['/some/path', 'some'],
35 ['/some/other-path', 'some'],
36 ['/some/other/path', 'some/other'],
37 ['/some/other/path?q=foo&b=bar', 'some/other'],