BaseTestCase: provide db for our tests
This commit is contained in:
parent
f9c694d39d
commit
77804d2b37
|
@ -3,17 +3,31 @@
|
|||
namespace Icinga\Module\Director\Test;
|
||||
|
||||
use Icinga\Application\Cli;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Module\Director\Db;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
class BaseTestCase extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private static $app;
|
||||
|
||||
private $db;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->app();
|
||||
}
|
||||
|
||||
protected function getDb()
|
||||
{
|
||||
if ($this->db === null) {
|
||||
$resourceName = Config::module('director')->get('db', 'resource');
|
||||
$this->db = Db::fromResourceName($resourceName);
|
||||
}
|
||||
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
protected function app()
|
||||
{
|
||||
if (self::$app === null) {
|
||||
|
|
|
@ -2,24 +2,15 @@
|
|||
|
||||
namespace Tests\Icinga\Modules\Director\Objects;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Module\Director\Db;
|
||||
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 TimePeriodRangesTest extends BaseTestCase
|
||||
class IcingaTimePeriodRangesTest extends BaseTestCase
|
||||
{
|
||||
protected $testPeriodName = '___TEST___timerange';
|
||||
|
||||
public function getDb()
|
||||
{
|
||||
$resourceName = Config::module('director')->get('db', 'resource');
|
||||
$db = Db::fromResourceName($resourceName);
|
||||
return $db;
|
||||
}
|
||||
|
||||
public function testUpdate()
|
||||
{
|
||||
$period = $this->createTestPeriod();
|
||||
|
|
Loading…
Reference in New Issue