This commit is contained in:
Andrew Nicols 2019-08-07 10:22:04 +08:00
commit 638097810d
2 changed files with 42 additions and 2 deletions

View file

@ -830,4 +830,39 @@ EXPECTED;
$extracteddraftareas = extract_draft_file_urls_from_text($html, false, 5, 'user', 'draft');
$this->assertEquals($draftareas, $extracteddraftareas);
}
public function test_print_password_policy() {
$this->resetAfterTest(true);
global $CFG;
$policydisabled = '';
// Set password policy to disabled.
$CFG->passwordpolicy = false;
// Check for empty response.
$this->assertEquals($policydisabled, print_password_policy());
// Now set the policy to enabled with every control disabled.
$CFG->passwordpolicy = true;
$CFG->minpasswordlength = 0;
$CFG->minpassworddigits = 0;
$CFG->minpasswordlower = 0;
$CFG->minpasswordupper = 0;
$CFG->minpasswordnonalphanum = 0;
$CFG->maxconsecutiveidentchars = 0;
// Check for empty response.
$this->assertEquals($policydisabled, print_password_policy());
// Now enable some controls, and check that the policy responds with policy text.
$CFG->minpasswordlength = 8;
$CFG->minpassworddigits = 1;
$CFG->minpasswordlower = 1;
$CFG->minpasswordupper = 1;
$CFG->minpasswordnonalphanum = 1;
$CFG->maxconsecutiveidentchars = 1;
$this->assertNotEquals($policydisabled, print_password_policy());
}
}