You are here

protected function NodeAccessGrantsCacheContextTest::assertUserCacheContext in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Tests/NodeAccessGrantsCacheContextTest.php \Drupal\node\Tests\NodeAccessGrantsCacheContextTest::assertUserCacheContext()

Asserts that for each given user, the expected cache context is returned.

Parameters

array $expected: Expected values, keyed by user ID, expected cache contexts as values.

1 call to NodeAccessGrantsCacheContextTest::assertUserCacheContext()
NodeAccessGrantsCacheContextTest::testCacheContext in core/modules/node/src/Tests/NodeAccessGrantsCacheContextTest.php
Tests NodeAccessGrantsCacheContext::getContext().

File

core/modules/node/src/Tests/NodeAccessGrantsCacheContextTest.php, line 68
Contains \Drupal\node\Tests\NodeAccessGrantsCacheContextTest.

Class

NodeAccessGrantsCacheContextTest
Tests the node access grants cache context service.

Namespace

Drupal\node\Tests

Code

protected function assertUserCacheContext(array $expected) {
  foreach ($expected as $uid => $context) {
    if ($uid > 0) {
      $this
        ->drupalLogin($this->userMapping[$uid]);
    }
    $this
      ->pass('Asserting cache context for user ' . $uid . '.');
    $this
      ->assertIdentical($context, $this->container
      ->get('cache_context.user.node_grants')
      ->getContext('view'));
  }
  $this
    ->drupalLogout();
}