function PasswordHashingTest::testPasswordHashing
Same name in other branches
- 7.x modules/simpletest/tests/password.test \PasswordHashingTest::testPasswordHashing()
- 9 core/tests/Drupal/Tests/Core/Password/PasswordHashingTest.php \Drupal\Tests\Core\Password\PasswordHashingTest::testPasswordHashing()
Test password hashing.
@covers ::hash @covers ::getCountLog2 @covers ::check @covers ::needsRehash
File
-
core/
tests/ Drupal/ Tests/ Core/ Password/ PasswordHashingTest.php, line 97
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.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.