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