diff --git a/core/lib/Drupal/Core/Session/AccountProxy.php b/core/lib/Drupal/Core/Session/AccountProxy.php index 8e85cf2..cb6fbd2 100644 --- a/core/lib/Drupal/Core/Session/AccountProxy.php +++ b/core/lib/Drupal/Core/Session/AccountProxy.php @@ -126,7 +126,7 @@ public function revertAccount() { $this->account = array_pop($this->accountStack); } else { - throw new \RuntimeException(t('No more account impersonations to revert.')); + throw new \RuntimeException('No more account impersonations to revert.'); } // Restore original session saving status if all impersonations are reverted. if (empty($this->accountStack)) { @@ -147,7 +147,7 @@ public function revertAll() { $this->accountStack = array(); } else { - throw new \RuntimeException(t('No more account impersonations to revert.')); + throw new \RuntimeException('No more account impersonations to revert.'); } // Restore original session saving status if all impersonations are reverted. if ($this->originalSessionSaving) { diff --git a/core/modules/system/lib/Drupal/system/Tests/Session/UserImpersonatingUserTest.php b/core/modules/system/src/Tests/Session/UserImpersonatingUserTest.php similarity index 87% rename from core/modules/system/lib/Drupal/system/Tests/Session/UserImpersonatingUserTest.php rename to core/modules/system/src/Tests/Session/UserImpersonatingUserTest.php index 7b715fa..2222e58 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Session/UserImpersonatingUserTest.php +++ b/core/modules/system/src/Tests/Session/UserImpersonatingUserTest.php @@ -2,19 +2,19 @@ /** * @file - * Contains Drupal\user\Tests\UserImpersonatingUserTest. + * Contains Drupal\system\Tests\Session\UserImpersonatingUserTest. */ namespace Drupal\system\Tests\Session; use Drupal\Core\Session\AnonymousUserSession; use Drupal\Core\Session\UserSession; -use Drupal\simpletest\WebTestBase; +use Drupal\simpletest\KernelTestBase; /** * Test case for impersonating users. */ -class UserImpersonatingUserTest extends WebTestBase { +class UserImpersonatingUserTest extends KernelTestBase { public static function getInfo() { return array( @@ -28,8 +28,7 @@ function testUserImpersonateUser() { $session_manager = $this->container->get('session_manager'); $user = $this->container->get('current_user'); $original_user = clone $user; - $this->verbose('Session saving status: '. var_dump($session_manager->isEnabled())); - $this->assertFalse($session_manager->isEnabled(), 'Session saving is initially disabled.'); + $original_session_saving = $session_manager->isEnabled(); // If not currently logged in, use AccountProxy::impersonateAccount() to switch to // user 1. If logged in, switch to the anonymous user instead. @@ -67,8 +66,8 @@ function testUserImpersonateUser() { // Assert that the original user is the active user again, and that session // saving has been re-enabled. - $this->assertEqual($user->id(), $original_user->id(), 'Original user successfully restored.'); - $this->assertTrue($session_manager->isEnabled(), 'Session saving is enabled.'); + $this->assertEqual($user->id(), $original_user->id(), 'Original user correctly restored.'); + $this->assertEqual($session_manager->isEnabled(), $original_session_saving, 'Original session saving correctly restored.'); // Verify that AccountProxy::revertAccount and AccountProxy::revertAll() // will throw exceptions if there is none left in the stack.