mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-25 18:59:05 +02:00
IcingaConfigHelper: empty intervals are null
This commit is contained in:
parent
7f949e1b5a
commit
11e5ef0362
@ -171,6 +171,10 @@ class IcingaConfigHelper
|
|||||||
|
|
||||||
public static function parseInterval($interval)
|
public static function parseInterval($interval)
|
||||||
{
|
{
|
||||||
|
if ($interval === null || $interval === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (ctype_digit($interval)) {
|
if (ctype_digit($interval)) {
|
||||||
return (int) $interval;
|
return (int) $interval;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ class IcingaConfigHelperTest extends BaseTestCase
|
|||||||
{
|
{
|
||||||
public function testWhetherIntervalStringIsCorrectlyParsed()
|
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('10'), 10);
|
||||||
$this->assertEquals(c::parseInterval('70s'), 70);
|
$this->assertEquals(c::parseInterval('70s'), 70);
|
||||||
$this->assertEquals(c::parseInterval('5m 10s'), 310);
|
$this->assertEquals(c::parseInterval('5m 10s'), 310);
|
||||||
@ -24,6 +26,12 @@ class IcingaConfigHelperTest extends BaseTestCase
|
|||||||
c::parseInterval('1h 5m 60x');
|
c::parseInterval('1h 5m 60x');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testWhetherAnEmptyValueGivesNull()
|
||||||
|
{
|
||||||
|
$this->assertNull(c::parseInterval(''));
|
||||||
|
$this->assertNull(c::parseInterval(null));
|
||||||
|
}
|
||||||
|
|
||||||
public function testWhetherIntervalStringIsCorrectlyRendered()
|
public function testWhetherIntervalStringIsCorrectlyRendered()
|
||||||
{
|
{
|
||||||
$this->assertEquals(c::renderInterval(10), '10s');
|
$this->assertEquals(c::renderInterval(10), '10s');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user