public function MasqueradeCacheTest::testMasqueradeSwitchBlockCaching in Masquerade 8.2
Tests caching for the user switch block.
File
- tests/
src/ Functional/ MasqueradeCacheTest.php, line 29
Class
- MasqueradeCacheTest
- Tests caching for masquerade.
Namespace
Drupal\Tests\masquerade\FunctionalCode
public function testMasqueradeSwitchBlockCaching() {
// Create two masquerade users.
$umberto = $this
->drupalCreateUser([
'masquerade as any user',
'access content',
], 'umberto');
$nelle = $this
->drupalCreateUser([
'masquerade as any user',
'access content',
], 'nelle');
// Add the Masquerade block to the sidebar.
$masquerade_block = $this
->drupalPlaceBlock('masquerade');
// Login as Umberto.
$this
->drupalLogin($umberto);
$this
->drupalGet('<front>');
$this
->assertBlockAppears($masquerade_block);
// Masquerade as Nelle.
$edit = [
'masquerade_as' => $nelle
->getAccountName(),
];
$this
->submitForm($edit, 'Switch');
$this
->drupalGet('<front>');
$this
->assertNoBlockAppears($masquerade_block);
// Logout, and log in as Nelle.
$this
->drupalLogout();
$this
->drupalLogin($nelle);
$this
->drupalGet('<front>');
$this
->assertBlockAppears($masquerade_block);
// Validate cache contexts for block with permissions of user.
$this
->validateMasqueradeBlock($masquerade_block
->id());
}