PhpPasswordUnknownAlgorithmIntegrationTest.php
Namespace
Drupal\KernelTests\Core\PasswordFile
-
core/
tests/ Drupal/ KernelTests/ Core/ Password/ PhpPasswordUnknownAlgorithmIntegrationTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\KernelTests\Core\Password;
// cspell:ignore vogon
use Drupal\Core\Password\PasswordInterface;
use Drupal\Core\Password\PhpPassword;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
/**
* Integration tests for the PHP password hashing service.
*/
class PhpPasswordUnknownAlgorithmIntegrationTest extends PasswordTestBase {
/**
* {@inheritdoc}
*/
protected ?string $passwordAlgorithm = 'vogon poetry';
/**
* {@inheritdoc}
*/
protected ?array $passwordOptions = [
'bureaucracy' => 'max',
'temper' => 'very bad',
];
/**
* Tests that the default password hashing algorithm is used.
*/
public function testUnknownAlgorithmHashing() : void {
$password = 'correct horse battery staple';
$hash = $this->container
->get(PasswordInterface::class)
->hash($password);
$defaultOptions = sprintf("%02d", PASSWORD_BCRYPT_DEFAULT_COST);
$this->assertStringStartsWith(implode([
'$',
PASSWORD_DEFAULT,
'$',
$defaultOptions,
]), $hash);
}
}
Classes
| Title | Deprecated | Summary |
|---|---|---|
| PhpPasswordUnknownAlgorithmIntegrationTest | Integration tests for the PHP password hashing service. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.