diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php
index db2900c..6d5998b 100644
--- a/core/lib/Drupal/Core/Form/FormBuilder.php
+++ b/core/lib/Drupal/Core/Form/FormBuilder.php
@@ -1250,14 +1250,8 @@ protected function drupalStaticReset($name = NULL) {
    * @return \Drupal\Core\Session\AccountInterface
    */
   protected function currentUser() {
-    if (!$this->currentUser) {
-      if (\Drupal::hasService('current_user')) {
-        $this->currentUser = \Drupal::currentUser();
-      }
-      else {
-        global $user;
-        $this->currentUser = $user;
-      }
+    if (!$this->currentUser && \Drupal::hasService('current_user')) {
+      $this->currentUser = \Drupal::currentUser();
     }
     return $this->currentUser;
   }
diff --git a/core/modules/history/src/Tests/Views/HistoryTimestampTest.php b/core/modules/history/src/Tests/Views/HistoryTimestampTest.php
index 252d24c..38b6fb3 100644
--- a/core/modules/history/src/Tests/Views/HistoryTimestampTest.php
+++ b/core/modules/history/src/Tests/Views/HistoryTimestampTest.php
@@ -43,7 +43,7 @@ public function testHandlers() {
 
     $account = $this->drupalCreateUser();
     $this->drupalLogin($account);
-    $GLOBALS['user'] = $account;
+    \Drupal::currentUser()->setCurrentUser($account);
 
     db_insert('history')
       ->fields(array(
diff --git a/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php b/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php
index 0a3f439..4a16236 100644
--- a/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php
+++ b/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php
@@ -29,17 +29,16 @@ public function test_plugin_argument_default_current_user() {
 
     // Switch the user, we have to check the global user too, because drupalLogin is only for the simpletest browser.
     $this->drupalLogin($account);
-    global $user;
-    $admin = $user;
+    $admin = \Drupal::currentUser();
     $session_manager = \Drupal::service('session_manager')->disable();
-    $user = $account;
+    \Drupal::currentUser()->setCurrentUser($account);
 
     $view = Views::getView('test_plugin_argument_default_current_user');
     $view->initHandlers();
 
     $this->assertEqual($view->argument['null']->getDefaultArgument(), $account->id(), 'Uid of the current user is used.');
     // Switch back.
-    $user = $admin;
+    \Drupal::currentUser()->setCurrentUser($admin);
     $session_manager->enable();
   }
 
