commit 8798f59f4964ffd425663a940532ddbb21e40bf7 Author: Joel Pittet Date: Fri Oct 25 22:37:50 2013 -0700 6 diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php index 4511346..53a79e7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php @@ -94,7 +94,7 @@ function testAdminDefinedFormatDate() { * Tests the format_date() function. */ function testFormatDate() { - global $user; + $user = \Drupal::currentUser(); $language_interface = language(Language::TYPE_INTERFACE); @@ -127,7 +127,7 @@ function testFormatDate() { $edit = array('preferred_langcode' => self::LANGCODE, 'mail' => $test_user->getEmail(), 'timezone' => 'America/Los_Angeles'); $this->drupalPostForm('user/' . $test_user->id() . '/edit', $edit, t('Save')); - // Disable session saving as we are about to modify the global $user. + // Disable session saving as we are about to modify the current user. drupal_save_session(FALSE); // Save the original user and language and then replace it with the test user and language. $real_user = $user; diff --git a/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php b/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php index 3707bf8..c8159e0 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php @@ -57,7 +57,7 @@ public function testSystemTimezone() { * stated timezones. */ public function testDateTimezone() { - global $user; + $user = \Drupal::currentUser(); $date_string = '2007-01-31 21:00:00'; @@ -99,7 +99,7 @@ public function testDateTimezone() { $edit = array('mail' => $test_user->getEmail(), 'timezone' => 'Asia/Manila'); $this->drupalPostForm('user/' . $test_user->id() . '/edit', $edit, t('Save')); - // Disable session saving as we are about to modify the global $user. + // Disable session saving as we are about to modify the current user. drupal_save_session(FALSE); // Save the original user and then replace it with the test user. $real_user = $user; diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php index 373c90b..9ed21c5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php @@ -60,7 +60,6 @@ function assertEntityAccess($ops, AccessibleInterface $object, AccountInterface */ function testEntityAccess() { // Set up a non-admin user that is allowed to view test entities. - global $user; $user = $this->createUser(array('uid' => 2), array('view test entity')); $entity = entity_create('entity_test', array( 'name' => 'test', @@ -89,7 +88,6 @@ function testEntityAccess() { */ function testEntityAccessDefaultController() { // The implementation requires that the global user id can be loaded. - global $user; $user = $this->createUser(array('uid' => 2)); // Check that the default access controller is used for entities that don't @@ -112,7 +110,6 @@ function testEntityAccessDefaultController() { function testEntityTranslationAccess() { // Set up a non-admin user that is allowed to view test entity translations. - global $user; $user = $this->createUser(array('uid' => 2), array('view test entity translations')); // Create two test languages. diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index e2b0d4f..ffb3d59 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -108,7 +108,7 @@ public function testEntityLanguageMethods() { protected function _testEntityLanguageMethods($entity_type) { $entity = entity_create($entity_type, array( 'name' => 'test', - 'user_id' => $GLOBALS['user']->id(), + 'user_id' => \Drupal::currentUser()->id(), )); $this->assertEqual($entity->language()->id, Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', array('%entity_type' => $entity_type))); $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type))); diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php index 6d293cd..6bf6fa0 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php @@ -32,7 +32,7 @@ function testTokenReplacement() { $account = $this->drupalCreateUser(); $node = $this->drupalCreateNode(array('uid' => $account->id())); $node->title = 'Blinking Text'; - $user = $this->container->get('current_user'); + $user = \Drupal::currentUser(); $language_interface = language(Language::TYPE_INTERFACE); $source = '[node:title]'; // Title of the node we passed in diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php index d72ed54..6723f47 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php @@ -89,7 +89,7 @@ protected function checkRequirements() { * @see \Drupal\simpletest\WebTestBase::prepareEnvironment() */ protected function setUp() { - global $user, $conf; + global $conf; // Load the Update API. require_once DRUPAL_ROOT . '/core/includes/update.inc'; @@ -162,7 +162,7 @@ protected function setUp() { $this->profile = $install_profile; // Ensure that the session is not written to the new environment and replace - // the global $user session with uid 1 from the new test site. + // the current user session with uid 1 from the new test site. drupal_save_session(FALSE); // Load values for uid 1. $values = db_query('SELECT * FROM {users} WHERE uid = :uid', array(':uid' => 1))->fetchAssoc();