Commit a8de3331 authored by jun's avatar jun
Browse files

Merge branch 'MDL-74886-master' of https://github.com/lameze/moodle

parents 6a55fb96 3fc9e345
......@@ -4010,7 +4010,9 @@ class admin_setting_configduration extends admin_setting {
return '';
}
$seconds = (int)($data['v']*$data['u']);
$unit = (int)$data['u'];
$value = (int)$data['v'];
$seconds = $value * $unit;
// Validate the new setting.
$error = $this->validate_setting($seconds);
......
......@@ -357,6 +357,17 @@ class core_admintree_testcase extends advanced_testcase {
$this->assertSame('', get_config('abc_cde', 'execpath'));
}
/**
* Test setting an empty duration displays the correct validation message.
*/
public function test_emptydurationvalue() {
$this->resetAfterTest();
$adminsetting = new admin_setting_configduration('abc_cde/duration', 'some desc', '', '');
// A value that isn't a number is treated as a zero, so we expect to see no error message.
$this->assertEmpty($adminsetting->write_setting(['u' => '3600', 'v' => 'abc']));
}
/**
* Test setting for blocked hosts
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment