function AdminAccountSwitcherTest::testSwitchToAndSwitchBack
File
-
core/
tests/ Drupal/ KernelTests/ Core/ DefaultContent/ AdminAccountSwitcherTest.php, line 84
Class
- AdminAccountSwitcherTest
- @covers \Drupal\Core\DefaultContent\AdminAccountSwitcher[[api-linebreak]] @group DefaultContent
Namespace
Drupal\KernelTests\Core\DefaultContentCode
public function testSwitchToAndSwitchBack() : void {
$this->assertTrue($this->container
->get('current_user')
->isAnonymous());
/** @var \Drupal\Core\Session\AccountInterface $account */
$account = $this->createUser();
$switcher = $this->container
->get(AdminAccountSwitcher::class);
$this->assertSame($switcher, $switcher->switchTo($account));
$this->assertSame($account->id(), $this->container
->get('current_user')
->id());
$this->assertSame($switcher, $switcher->switchBack());
$this->assertTrue($this->container
->get('current_user')
->isAnonymous());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.