mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2026-05-28 04:35:53 -04:00
IcingaConfigHelper: empty intervals are null
This commit is contained in:
parent
7f949e1b5a
commit
11e5ef0362
2 changed files with 12 additions and 0 deletions
|
|
@ -171,6 +171,10 @@ class IcingaConfigHelper
|
|||
|
||||
public static function parseInterval($interval)
|
||||
{
|
||||
if ($interval === null || $interval === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (ctype_digit($interval)) {
|
||||
return (int) $interval;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ class IcingaConfigHelperTest extends BaseTestCase
|
|||
{
|
||||
public function testWhetherIntervalStringIsCorrectlyParsed()
|
||||
{
|
||||
$this->assertEquals(c::parseInterval('0'), 0);
|
||||
$this->assertEquals(c::parseInterval('0s'), 0);
|
||||
$this->assertEquals(c::parseInterval('10'), 10);
|
||||
$this->assertEquals(c::parseInterval('70s'), 70);
|
||||
$this->assertEquals(c::parseInterval('5m 10s'), 310);
|
||||
|
|
@ -24,6 +26,12 @@ class IcingaConfigHelperTest extends BaseTestCase
|
|||
c::parseInterval('1h 5m 60x');
|
||||
}
|
||||
|
||||
public function testWhetherAnEmptyValueGivesNull()
|
||||
{
|
||||
$this->assertNull(c::parseInterval(''));
|
||||
$this->assertNull(c::parseInterval(null));
|
||||
}
|
||||
|
||||
public function testWhetherIntervalStringIsCorrectlyRendered()
|
||||
{
|
||||
$this->assertEquals(c::renderInterval(10), '10s');
|
||||
|
|
|
|||
Loading…
Reference in a new issue