PathParentCacheContextTest.php in Drupal 8
File
core/tests/Drupal/Tests/Core/Cache/Context/PathParentCacheContextTest.php
View source
<?php
namespace Drupal\Tests\Core\Cache\Context;
use Drupal\Core\Cache\Context\PathParentCacheContext;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
class PathParentCacheContextTest extends UnitTestCase {
public function testGetContext($original_path, $context) {
$request_stack = new RequestStack();
$request = Request::create($original_path);
$request_stack
->push($request);
$cache_context = new PathParentCacheContext($request_stack);
$this
->assertSame($cache_context
->getContext(), $context);
}
public function providerTestGetContext() {
return [
[
'/some/path',
'some',
],
[
'/some/other-path',
'some',
],
[
'/some/other/path',
'some/other',
],
[
'/some/other/path?q=foo&b=bar',
'some/other',
],
[
'/some',
'',
],
[
'/',
'',
],
];
}
}