mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-66280 core: Added unit tests for print_password_policy
This commit is contained in:
parent
e40ea418f4
commit
d82b6004bf
@ -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());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user