2020-11-09 22:37:47 +01:00
|
|
|
<?php
|
|
|
|
|
2021-03-22 10:28:28 +01:00
|
|
|
class PasswordValidationCallableTEst extends \PHPUnit\Framework\TestCase
|
|
|
|
{
|
2020-12-23 17:24:41 +01:00
|
|
|
public function setUp(): void {
|
2020-11-09 22:37:47 +01:00
|
|
|
$c = Config::getInstance();
|
|
|
|
|
|
|
|
$all = $c->getAll();
|
|
|
|
|
|
|
|
$all['password_validation'] = [
|
|
|
|
function ($pw) {
|
|
|
|
if ($pw === 'fail') {
|
|
|
|
return 'test_fail';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
unset($all['min_password_length']);
|
|
|
|
|
|
|
|
$c->setAll($all);
|
|
|
|
parent::setUp();
|
|
|
|
}
|
|
|
|
|
2020-12-23 17:24:41 +01:00
|
|
|
public function testBasic() {
|
2020-11-09 22:37:47 +01:00
|
|
|
// anything except 'fail' should work.
|
|
|
|
$this->assertEmpty(validate_password('str'));
|
|
|
|
$this->assertEquals([], validate_password('1234asdf'));
|
|
|
|
$this->assertEquals(['test_fail'], validate_password('fail'));
|
|
|
|
}
|
|
|
|
}
|