IcingaTimePeriodTest: stricter tests

This commit is contained in:
Thomas Gelf 2016-03-17 23:05:16 +01:00
parent 0ba23e8b4a
commit 3970f381dd
1 changed files with 26 additions and 6 deletions

View File

@ -2,16 +2,14 @@
namespace Tests\Icinga\Module\Director\Objects;
use Icinga\Module\Director\Objects\IcingaTimePeriodRange;
use Icinga\Module\Director\Objects\IcingaTimePeriodRanges;
use Icinga\Module\Director\Objects\IcingaTimePeriod;
use Icinga\Module\Director\Test\BaseTestCase;
class IcingaTimePeriodRangesTest extends BaseTestCase
class IcingaTimePeriodTest extends BaseTestCase
{
protected $testPeriodName = '___TEST___timerange';
protected $testPeriodName = '___TEST___timeperiod';
public function testWhetherUpdatedTimeperiodRangesAreCorrectlyStored()
public function testWhetherUpdatedTimeperiodsAreCorrectlyStored()
{
if ($this->skipForMissingDb()) {
return;
@ -24,7 +22,12 @@ class IcingaTimePeriodRangesTest extends BaseTestCase
'tuesday' => '18:00-24:00',
'wednesday' => '00:00-24:00',
);
$period->ranges()->set($newRanges);
$period->ranges = $newRanges;
$this->assertEquals(
'18:00-24:00',
$period->toPlainObject()->ranges->tuesday
);
$period->store();
$period = $this->loadTestPeriod();
@ -32,6 +35,23 @@ class IcingaTimePeriodRangesTest extends BaseTestCase
'18:00-24:00',
$period->ranges()->get('tuesday')->timeperiod_value
);
$this->assertEquals(
'00:00-24:00',
$period->toPlainObject()->ranges->wednesday
);
$period->ranges()->setRange('wednesday', '09:00-17:00');
$this->assertEquals(
'09:00-17:00',
$period->toPlainObject()->ranges->wednesday
);
$this->assertEquals(
'00:00-24:00',
$period->getPlainUnmodifiedObject()->ranges->wednesday
);
}
protected function createTestPeriod()