// Verify that the active user has changed, and that session saving is
// disabled.
$this->
assertEquals(2,
$user->
id(), 'Switched to user 2.'
);
$this->
assertFalse($session_handler->
isSessionWritable(), 'Session saving is disabled.'
);
// Perform a second (nested) user account switch.
$switcher->
switchTo(new UserSession(['uid' => 3
]));
$this->
assertEquals(3,
$user->
id(), 'Switched to user 3.'
);
// Revert to the user session that was active between the first and second
// switch.
$switcher->
switchBack();
// Since we are still in the account from the first switch, session handling
// still needs to be disabled.
$this->
assertEquals(2,
$user->
id(), 'Reverted to user 2.'
);
$this->
assertFalse($session_handler->
isSessionWritable(), 'Session saving still disabled.'
);
// Revert to the original account which was active before the first switch.
$switcher->
switchBack();
// Assert that the original account is active again, and that session saving
// has been re-enabled.