You are here

public function PageTest::testAddCacheContext in Hook Event Dispatcher 8

Test add cache context.

File

tests/src/Unit/Preprocess/PageTest.php, line 136

Class

PageTest
Class PageTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess

Code

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