function PathParentCacheContextTest::testGetContext

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Cache/Context/PathParentCacheContextTest.php \Drupal\Tests\Core\Cache\Context\PathParentCacheContextTest::testGetContext()
  2. 10 core/tests/Drupal/Tests/Core/Cache/Context/PathParentCacheContextTest.php \Drupal\Tests\Core\Cache\Context\PathParentCacheContextTest::testGetContext()
  3. 9 core/tests/Drupal/Tests/Core/Cache/Context/PathParentCacheContextTest.php \Drupal\Tests\Core\Cache\Context\PathParentCacheContextTest::testGetContext()
  4. 8.9.x core/tests/Drupal/Tests/Core/Cache/Context/PathParentCacheContextTest.php \Drupal\Tests\Core\Cache\Context\PathParentCacheContextTest::testGetContext()

Tests get context.

Attributes

#[DataProvider('providerTestGetContext')]

File

core/tests/Drupal/Tests/Core/Cache/Context/PathParentCacheContextTest.php, line 25

Class

PathParentCacheContextTest
Tests Drupal\Core\Cache\Context\PathParentCacheContext.

Namespace

Drupal\Tests\Core\Cache\Context

Code

public function testGetContext($original_path, $context) : void {
  $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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.