<?php

use Icinga\Module\Director\Objects\IcingaTimePeriodRange;
use Icinga\Module\Director\Objects\IcingaTimePeriodRanges;
use Icinga\Module\Director\Objects\IcingaTimePeriod;
use Icinga\Test\BaseTestCase;
use Icinga\Application\Config;
use Icinga\Module\Director\Db;
Icinga\Application\Config::$configDir = '/etc/icingaweb2';
/**
 * $ icingacli test php unit /usr/local/icingaweb-modules/director
 */
class TimePeriodRangesTest extends BaseTestCase
{
    public function testFoo()
    {
        $this->assertEquals('foo', 'foo');
    }
    public function getDb()
    {
        $resourceName = Config::module('director')->get('db', 'resource');
        $db = Db::fromResourceName($resourceName);
        return $db;
    }
    public function prepare()
    {
        $db = $this->getDb();
        $object = IcingaTimePeriod::load(1, $db);
        $ranges = $object->ranges();
        $newRanges = array('monday' => '00:00-24:00', 'tuesday' => '00:00-24:00', 'wednesday' => '00:00-24:00');
        $ranges->set($newRanges);
 /**
  * Load Configuration
  *
  * @return $this
  */
 protected function loadConfig()
 {
     Config::$configDir = $this->configDir;
     try {
         $this->config = Config::app();
     } catch (NotReadableError $e) {
         Logger::error(new IcingaException('Cannot load application configuration. An exception was thrown:', $e));
         $this->config = new Config();
     }
     return $this;
 }
Example #3
0
 /**
  * Reset config dir
  */
 public function tearDown()
 {
     parent::tearDown();
     Config::$configDir = $this->oldConfigDir;
 }