class UserPassRehashTest
Same name and namespace in other branches
- 11.x core/modules/user/tests/src/Kernel/UserPassRehashTest.php \Drupal\Tests\user\Kernel\UserPassRehashTest
Tests user_pass_rehash().
@group user
Hierarchy
- class \Drupal\Tests\user\Kernel\UserPassRehashTest
Expanded class hierarchy of UserPassRehashTest
File
-
core/
modules/ user/ tests/ src/ Kernel/ UserPassRehashTest.php, line 15
Namespace
Drupal\Tests\user\KernelView source
class UserPassRehashTest extends KernelTestBase {
use UserCreationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'user',
];
/**
* Tests uniqueness of hashes when no password is set.
*/
public function testUniqueHashNoPasswordValue() : void {
$this->installEntitySchema('user');
$timestamp = \Drupal::time()->getRequestTime();
$user_a = $this->createUser([], NULL, FALSE, [
'uid' => 12,
'mail' => '3user@example.com',
'login' => $timestamp - 1000,
]);
$user_b = $this->createUser([], NULL, FALSE, [
'uid' => 123,
'mail' => 'user@example.com',
'login' => $timestamp - 1000,
]);
// Unset passwords after the users are created in order to avoid
// (different) password hashes being generated for the empty strings.
$user_a->setPassword('');
$user_b->setPassword('');
$hash_a = user_pass_rehash($user_a, $timestamp);
$hash_b = user_pass_rehash($user_b, $timestamp);
$this->assertNotEquals($hash_a, $hash_b);
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary |
---|---|---|---|---|
ConfigTestTrait::configImporter | protected | function | Returns a ConfigImporter object to import test configuration. | |
ConfigTestTrait::copyConfig | protected | function | Copies configuration objects from source storage to target storage. | |
ExtensionListTestTrait::getModulePath | protected | function | Gets the path for the specified module. | |
ExtensionListTestTrait::getThemePath | protected | function | Gets the path for the specified theme. | |
RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | |
RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | |
RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait::randomStringValidate | Deprecated | public | function | Callback for random string validation. |
StorageCopyTrait::replaceStorageContents | protected static | function | Copy the configuration from one storage to another and remove stale items. | |
TestRequirementsTrait::checkModuleRequirements | Deprecated | private | function | Checks missing module requirements. |
TestRequirementsTrait::checkRequirements | Deprecated | protected | function | Check module requirements for the Drupal use case. |
TestRequirementsTrait::getDrupalRoot | protected static | function | Returns the Drupal root directory. | |
UserPassRehashTest::$modules | protected static | property | Modules to install. | |
UserPassRehashTest::testUniqueHashNoPasswordValue | public | function | Tests uniqueness of hashes when no password is set. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.