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