1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
<?php
namespace Icinga\Module\Businessprocess\Test;
use Icinga\Application\Config;
use Icinga\Application\ApplicationBootstrap;
use Icinga\Application\Icinga;
use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\Storage\LegacyStorage;
abstract class BaseTestCase extends \Icinga\Test\BaseTestCase
{
/** @var ApplicationBootstrap */
private static $app;
public function setUp(): void
{
parent::setUp();
$this->getRequestMock()->shouldReceive('getBaseUrl')->andReturn('/icingaweb2/');
$this->app()
->getModuleManager()
->loadModule('businessprocess');
}
protected function emptyConfigSection()
{
return Config::module('businessprocess')->getSection('global');
}
/***
* @return BpConfig
*/
protected function makeLoop()
{
return $this->makeInstance()->loadFromString(
'loop',
"a = b\nb = c\nc = a\nd = a"
);
}
/**
* @return LegacyStorage
*/
protected function makeInstance()
{
return new LegacyStorage($this->emptyConfigSection());
}
/**
* @param ?string $subDir
* @return string
*/
protected function getTestsBaseDir($subDir = null)
{
$dir = dirname(dirname(dirname(__DIR__))) . '/test';
if ($subDir === null) {
return $dir;
} else {
return $dir . '/' . ltrim($subDir, '/');
}
}
/**
* @return ApplicationBootstrap
*/
protected function app()
{
if (self::$app === null) {
self::$app = Icinga::app();
}
return self::$app;
}
}
|