mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 11:56:40 +02:00
MDL-67898 check: Get component if not set by manager
This commit is contained in:
parent
b58d1fd4e2
commit
bc4df2af71
2 changed files with 34 additions and 5 deletions
|
@ -26,6 +26,7 @@ use core\check\security\passwordpolicy;
|
|||
* @category check
|
||||
* @copyright 2020 Brendan Heywood <brendan@catalyst-au.net>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \core\check
|
||||
*/
|
||||
class check_test extends \advanced_testcase {
|
||||
|
||||
|
@ -36,7 +37,7 @@ class check_test extends \advanced_testcase {
|
|||
* instead of build time so many checks in real life such as testing
|
||||
* an API is connecting aren't viable to unit test.
|
||||
*/
|
||||
public function test_passwordpolicy() {
|
||||
public function test_passwordpolicy(): void {
|
||||
global $CFG;
|
||||
$prior = $CFG->passwordpolicy;
|
||||
|
||||
|
@ -52,5 +53,19 @@ class check_test extends \advanced_testcase {
|
|||
|
||||
$CFG->passwordpolicy = $prior;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the component is correctly set.
|
||||
*/
|
||||
public function test_get_component(): void {
|
||||
$check = new \tool_task\check\maxfaildelay();
|
||||
|
||||
// If no component is set, it should return the one based off the namespace.
|
||||
$this->assertEquals('tool_task', $check->get_component());
|
||||
|
||||
// However if one is set, it should return that.
|
||||
$check->set_component('test component');
|
||||
$this->assertEquals('test component', $check->get_component());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue