You are here

protected function MasqueradeCacheTest::validateMasqueradeBlock in Masquerade 8.2

Validates block entity cache contexts.

Parameters

string $bid: The block ID to load and validate.

1 call to MasqueradeCacheTest::validateMasqueradeBlock()
MasqueradeCacheTest::testMasqueradeSwitchBlockCaching in tests/src/Functional/MasqueradeCacheTest.php
Tests caching for the user switch block.

File

tests/src/Functional/MasqueradeCacheTest.php, line 97

Class

MasqueradeCacheTest
Tests caching for masquerade.

Namespace

Drupal\Tests\masquerade\Functional

Code

protected function validateMasqueradeBlock($bid) {

  /** @var \Drupal\block\Entity\Block $block */
  $block = Block::load($bid);
  $this
    ->assertContains('session.is_masquerading', $block
    ->getPlugin()
    ->getCacheContexts());

  /** @var \Drupal\Core\Access\AccessResult $result */
  $result = $block
    ->access('view', NULL, TRUE);
  $this
    ->assertContains('session.is_masquerading', $result
    ->getCacheContexts());
}