mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-05-28 04:34:08 -04:00
Test: add base test framework
This commit is contained in:
parent
95d8696705
commit
9e17ff21ba
6 changed files with 102 additions and 0 deletions
47
library/Businessprocess/Test/BaseTestCase.php
Normal file
47
library/Businessprocess/Test/BaseTestCase.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Businessprocess\Test;
|
||||
|
||||
use Icinga\Application\ApplicationBootstrap;
|
||||
use Icinga\Application\Icinga;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
abstract class BaseTestCase extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/** @var ApplicationBootstrap */
|
||||
private static $app;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->app();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $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;
|
||||
}
|
||||
}
|
||||
28
library/Businessprocess/Test/Bootstrap.php
Normal file
28
library/Businessprocess/Test/Bootstrap.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Businessprocess\Test;
|
||||
|
||||
use Icinga\Application\Cli;
|
||||
|
||||
class Bootstrap
|
||||
{
|
||||
public static function cli($basedir = null)
|
||||
{
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
if ($basedir === null) {
|
||||
$basedir = dirname(dirname(dirname(__DIR__)));
|
||||
}
|
||||
$testsDir = $basedir . '/test';
|
||||
require_once 'Icinga/Application/Cli.php';
|
||||
|
||||
if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) {
|
||||
$configDir = $_SERVER['ICINGAWEB_CONFIGDIR'];
|
||||
} else {
|
||||
$configDir = $testsDir . '/config';
|
||||
}
|
||||
|
||||
Cli::start($testsDir, $configDir)
|
||||
->getModuleManager()
|
||||
->loadModule('businessprocess', $basedir);
|
||||
}
|
||||
}
|
||||
18
phpunit.xml
Normal file
18
phpunit.xml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="test/bootstrap.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Businessprocess PHP Unit tests">
|
||||
<directory suffix=".php">test/php</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
9
test/bootstrap.php
Normal file
9
test/bootstrap.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
use Icinga\Module\Businessprocess\Test\Bootstrap;
|
||||
|
||||
call_user_func(function() {
|
||||
$basedir = dirname(__DIR__);
|
||||
require_once $basedir . '/library/Businessprocess/Test/Bootstrap.php';
|
||||
Bootstrap::cli($basedir);
|
||||
});
|
||||
0
test/config/authentication.ini
Normal file
0
test/config/authentication.ini
Normal file
0
test/config/config.ini
Normal file
0
test/config/config.ini
Normal file
Loading…
Reference in a new issue