MDL-67898 check: Get component if not set by manager

This commit is contained in:
Matthew Hilton 2023-11-02 10:59:06 +10:00
parent b58d1fd4e2
commit bc4df2af71
No known key found for this signature in database
GPG key ID: DEE897B8DA89460B
2 changed files with 34 additions and 5 deletions

View file

@ -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());
}
}