0
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2024-09-19 19:22:14 +02:00
postfixadmin/tests/PasswordValidationCallableTest.php

32 lines
764 B
PHP
Raw Normal View History

<?php
2021-03-22 10:28:28 +01:00
class PasswordValidationCallableTEst extends \PHPUnit\Framework\TestCase
{
2021-04-13 22:19:16 +02:00
public function setUp(): void
{
$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();
}
2021-04-13 22:19:16 +02:00
public function testBasic()
{
// anything except 'fail' should work.
$this->assertEmpty(validate_password('str'));
$this->assertEquals([], validate_password('1234asdf'));
$this->assertEquals(['test_fail'], validate_password('fail'));
}
}