function QueryArgsCacheContextTest::testGetContext

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

@covers ::getContext

@dataProvider providerTestGetContext

File

core/tests/Drupal/Tests/Core/Cache/Context/QueryArgsCacheContextTest.php, line 23

Class

QueryArgsCacheContextTest
@coversDefaultClass \Drupal\Core\Cache\Context\QueryArgsCacheContext @group Cache

Namespace

Drupal\Tests\Core\Cache\Context

Code

public function testGetContext(array $query_args, $cache_context_parameter, $context) : void {
    $request_stack = new RequestStack();
    $request = Request::create('/', 'GET', $query_args);
    $request_stack->push($request);
    $cache_context = new QueryArgsCacheContext($request_stack);
    $this->assertSame($cache_context->getContext($cache_context_parameter), $context);
}

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