You are here

public function PageTest::testAddCacheContext in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 modules/preprocess_event_dispatcher/tests/src/Unit/PageTest.php \Drupal\Tests\preprocess_event_dispatcher\Unit\PageTest::testAddCacheContext()

Test add cache context.

File

modules/preprocess_event_dispatcher/tests/src/Unit/PageTest.php, line 121

Class

PageTest
Class PageTest.

Namespace

Drupal\Tests\preprocess_event_dispatcher\Unit

Code

public function testAddCacheContext() : void {
  $vars = [];
  $page = new PageEventVariables($vars);
  $page
    ->addCacheContext('url.path');
  $expectedVars = [];
  $expectedVars['#cache']['contexts'][] = 'url.path';
  self::assertSame($expectedVars, $vars);
}