diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 0a5cc0a..32db6c5 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -14,6 +14,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\Database\ConnectionNotDefinedException; use Drupal\Core\Language\Language; +use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\UserSession; use PDO; use stdClass; @@ -615,12 +616,12 @@ protected function checkPermissions(array $permissions, $reset = FALSE) { * $account->pass_raw = $pass_raw; * @endcode * - * @param \Drupal\user\UserInterface $account + * @param \Drupal\Core\Session\AccountInterface $account * User object representing the user to log in. * * @see drupalCreateUser() */ - protected function drupalLogin($account) { + protected function drupalLogin(AccountInterface $account) { if ($this->loggedInUser) { $this->drupalLogout(); } diff --git a/core/modules/system/lib/Drupal/system/Tests/System/PasswordHashingTest.php b/core/modules/system/lib/Drupal/system/Tests/System/PasswordHashingTest.php index 10ec647..7b61c15 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/PasswordHashingTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/PasswordHashingTest.php @@ -7,13 +7,21 @@ namespace Drupal\system\Tests\System; -use Drupal\simpletest\UnitTestBase; +use Drupal\simpletest\DrupalUnitTestBase; use Drupal\Core\Password\PhpassHashedPassword; /** * Unit tests for password hashing API. */ -class PasswordHashingTest extends UnitTestBase { +class PasswordHashingTest extends DrupalUnitTestBase { + + /** + * Modules to enable. + * + * @var array + */ + public static $modules = array('user'); + public static function getInfo() { return array( 'name' => 'Password hashing', @@ -31,13 +39,13 @@ function testPasswordHashing() { $password_hasher = new PhpassHashedPassword(1); // Set up a fake $account with a password 'baz', hashed with md5. $password = 'baz'; - $account = (object) array('name' => 'foo', 'pass' => md5($password)); + $account = entity_create('user', array('name' => 'foo', 'pass' => md5($password))); // The md5 password should be flagged as needing an update. $this->assertTrue($password_hasher->userNeedsNewHash($account), 'User with md5 password needs a new hash.'); // Re-hash the password. $old_hash = $account->getPassword(); - $account->pass = $password_hasher->hash($password); - $this->assertIdentical($password_hasher->getCountLog2($account->pass), $password_hasher::MIN_HASH_COUNT, 'Re-hashed password has the minimum number of log2 iterations.'); + $account->setPassword($password_hasher->hash($password)); + $this->assertIdentical($password_hasher->getCountLog2($account->getPassword()), $password_hasher::MIN_HASH_COUNT, 'Re-hashed password has the minimum number of log2 iterations.'); $this->assertTrue($account->getPassword() != $old_hash, 'Password hash changed.'); $this->assertTrue($password_hasher->check($password, $account), 'Password check succeeds.'); // Since the log2 setting hasn't changed and the user has a valid password, @@ -49,8 +57,8 @@ function testPasswordHashing() { $this->assertTrue($password_hasher->userNeedsNewHash($account), 'User needs a new hash after incrementing the log2 count.'); // Re-hash the password. $old_hash = $account->getPassword(); - $account->pass = $password_hasher->hash($password); - $this->assertIdentical($password_hasher->getCountLog2($account->pass), $password_hasher::MIN_HASH_COUNT + 1, 'Re-hashed password has the correct number of log2 iterations.'); + $account->setPassword($password_hasher->hash($password)); + $this->assertIdentical($password_hasher->getCountLog2($account->getPassword()), $password_hasher::MIN_HASH_COUNT + 1, 'Re-hashed password has the correct number of log2 iterations.'); $this->assertTrue($account->getPassword() != $old_hash, 'Password hash changed again.'); // Now the hash should be OK. $this->assertFalse($password_hasher->userNeedsNewHash($account), 'Re-hashed password does not need a new hash.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php index b6feee4..2abff85 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php @@ -7,6 +7,8 @@ namespace Drupal\system\Tests\Upgrade; +use Drupal\Core\Session\UserSession; + /** * Performs major version release upgrade tests on a bare database. * @@ -45,20 +47,17 @@ public function testBasicMinimalUpgrade() { // Verify that we are still logged in. $this->finishUpgradeSession(); - $this->drupalLogin((object) array( + $user = new UserSession(array( 'uid' => 1, 'name' => 'admin', 'pass_raw' => 'drupal', )); + $this->drupalLogin($user); // The previous login should've triggered a password rehash, so login one // more time to make sure the new hash is readable. $this->drupalLogout(); - $this->drupalLogin((object) array( - 'uid' => 1, - 'name' => 'admin', - 'pass_raw' => 'drupal', - )); + $this->drupalLogin($user); // Test that the site name is correctly displayed. $this->assertText('drupal', 'The site name is correctly displayed.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareStandardUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareStandardUpgradePathTest.php index 148156e..37ad031 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareStandardUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareStandardUpgradePathTest.php @@ -7,6 +7,8 @@ namespace Drupal\system\Tests\Upgrade; +use Drupal\Core\Session\UserSession; + /** * Performs major version release upgrade tests on a bare database. * @@ -50,20 +52,17 @@ public function testBasicStandardUpgrade() { // Logout and verify that we can login back in with our initial password. $this->drupalLogout(); - $this->drupalLogin((object) array( + $user = new UserSession(array( 'uid' => 1, 'name' => 'admin', 'pass_raw' => 'drupal', )); + $this->drupalLogin($user); // The previous login should've triggered a password rehash, so login one // more time to make sure the new hash is readable. $this->drupalLogout(); - $this->drupalLogin((object) array( - 'uid' => 1, - 'name' => 'admin', - 'pass_raw' => 'drupal', - )); + $this->drupalLogin($user); // Test that the site name is correctly displayed. $this->assertText('drupal', 'The site name is correctly displayed.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledMinimalUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledMinimalUpgradePathTest.php index 4e28e13..86d2b10 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledMinimalUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledMinimalUpgradePathTest.php @@ -7,6 +7,8 @@ namespace Drupal\system\Tests\Upgrade; +use Drupal\Core\Session\UserSession; + /** * Performs major version release upgrade tests on a populated database. * @@ -49,20 +51,17 @@ public function testFilledMinimalUpgrade() { // Logout and verify that we can login back in with our initial password. $this->drupalLogout(); - $this->drupalLogin((object) array( + $user = new UserSession(array( 'uid' => 1, 'name' => 'admin', 'pass_raw' => 'drupal', )); + $this->drupalLogin($user); // The previous login should've triggered a password rehash, so login one // more time to make sure the new hash is readable. $this->drupalLogout(); - $this->drupalLogin((object) array( - 'uid' => 1, - 'name' => 'admin', - 'pass_raw' => 'drupal', - )); + $this->drupalLogin($user); // Test that the site name is correctly displayed. $this->assertText('drupal', 'The site name is correctly displayed.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledStandardUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledStandardUpgradePathTest.php index 9fedb35..0064c4c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledStandardUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledStandardUpgradePathTest.php @@ -7,6 +7,8 @@ namespace Drupal\system\Tests\Upgrade; +use Drupal\Core\Session\UserSession; + /** * Performs major version release upgrade tests on a populated database. * @@ -62,20 +64,17 @@ public function testFilledStandardUpgrade() { // Logout and verify that we can login back in with our initial password. $this->drupalLogout(); - $this->drupalLogin((object) array( + $user = new UserSession(array( 'uid' => 1, 'name' => 'admin', 'pass_raw' => 'drupal', )); + $this->drupalLogin($user); // The previous login should've triggered a password rehash, so login one // more time to make sure the new hash is readable. $this->drupalLogout(); - $this->drupalLogin((object) array( - 'uid' => 1, - 'name' => 'admin', - 'pass_raw' => 'drupal', - )); + $this->drupalLogin($user); // Test that the site name is correctly displayed. $this->assertText('drupal', 'The site name is correctly displayed.'); diff --git a/core/modules/user/lib/Drupal/user/UserAutocomplete.php b/core/modules/user/lib/Drupal/user/UserAutocomplete.php index a935200..4d36923 100644 --- a/core/modules/user/lib/Drupal/user/UserAutocomplete.php +++ b/core/modules/user/lib/Drupal/user/UserAutocomplete.php @@ -67,7 +67,7 @@ public function getMatches($string, $include_anonymous = FALSE) { } $result = $this->connection->select('users')->fields('users', array('name'))->condition('name', db_like($string) . '%', 'LIKE')->range(0, 10)->execute(); foreach ($result as $account) { - $matches[$account->getUsername()] = check_plain($account->getUsername()); + $matches[$account->name] = check_plain($account->name); } } diff --git a/core/modules/user/lib/Drupal/user/UserBCDecorator.php b/core/modules/user/lib/Drupal/user/UserBCDecorator.php index 7a5026b..320c0f9 100644 --- a/core/modules/user/lib/Drupal/user/UserBCDecorator.php +++ b/core/modules/user/lib/Drupal/user/UserBCDecorator.php @@ -171,7 +171,7 @@ public function setLastLoginTime($timestamp) { * {@inheritdoc} */ public function isActive() { - $this->decorated->isActive(); + return $this->decorated->isActive(); } /**