protected function MasqueradeAccessTest::assertCanMasqueradeAs in Masquerade 8.2
Asserts that the logged-in user can masquerade as a given target user.
Parameters
\Drupal\Core\Session\AccountInterface $target_account: The user to masquerade to.
Throws
\Behat\Mink\Exception\ExpectationException
1 call to MasqueradeAccessTest::assertCanMasqueradeAs()
- MasqueradeAccessTest::testAccess in tests/
src/ Functional/ MasqueradeAccessTest.php - Tests masquerade access for different source and target users.
File
- tests/
src/ Functional/ MasqueradeAccessTest.php, line 129
Class
- MasqueradeAccessTest
- Tests masquerade access mechanism.
Namespace
Drupal\Tests\masquerade\FunctionalCode
protected function assertCanMasqueradeAs(AccountInterface $target_account) {
$edit = [
'masquerade_as' => $target_account
->getAccountName(),
];
$this
->drupalGet('masquerade');
$this
->submitForm($edit, 'Switch');
$this
->assertSession()
->responseNotContains($this
->t('You are not allowed to masquerade as %name.', [
'%name' => $target_account
->getDisplayName(),
]));
$this
->clickLink('Unmasquerade');
}