public function PasswordHashingTest::testPasswordHashing in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Password/PasswordHashingTest.php \Drupal\Tests\Core\Password\PasswordHashingTest::testPasswordHashing()
Tests password hashing.
@covers ::hash @covers ::getCountLog2 @covers ::check @covers ::needsRehash
File
- core/
tests/ Drupal/ Tests/ Core/ Password/ PasswordHashingTest.php, line 97 - Contains \Drupal\Tests\Core\Password\PasswordHashingTest.
Class
- PasswordHashingTest
- Unit tests for password hashing API.
Namespace
Drupal\Tests\Core\PasswordCode
public function testPasswordHashing() {
$this
->assertSame(PhpassHashedPassword::MIN_HASH_COUNT, $this->passwordHasher
->getCountLog2($this->hashedPassword), 'Hashed password has the minimum number of log2 iterations.');
$this
->assertNotEquals($this->hashedPassword, $this->md5HashedPassword, 'Password hashes not the same.');
$this
->assertTrue($this->passwordHasher
->check($this->password, $this->md5HashedPassword), 'Password check succeeds.');
$this
->assertTrue($this->passwordHasher
->check($this->password, $this->hashedPassword), 'Password check succeeds.');
// Since the log2 setting hasn't changed and the user has a valid password,
// userNeedsNewHash() should return FALSE.
$this
->assertFalse($this->passwordHasher
->needsRehash($this->hashedPassword), 'Does not need a new hash.');
}