mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-18 15:06:17 -05:00
GitHub Actions: Use new PHP workflows (#487)
This PR switches to the new PHP workflow, which combines linting, static analysis, and unit testing. `phpcs.xml` and `phpunit.xml` have been removed, as the new workflow provides sane defaults for both and the files did not contain any special configurations anyway. Since the new workflow uses the latest PHPUnit version by default, deprecated PHPUnit features have been migrated. In addition, code style corrections were made to comply with the latest PSR coding standards.
This commit is contained in:
commit
b4b41f7c6b
43 changed files with 108 additions and 359 deletions
92
.github/workflows/php.yml
vendored
92
.github/workflows/php.yml
vendored
|
|
@ -1,84 +1,26 @@
|
|||
name: PHP Tests
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- support/*
|
||||
- release/*
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Static analysis for php ${{ matrix.php }} on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php: ['8.2', '8.3', '8.4']
|
||||
os: ['ubuntu-latest']
|
||||
|
||||
steps:
|
||||
- name: Checkout code base
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
tools: phpcs
|
||||
|
||||
- name: Setup dependencies
|
||||
run: composer require -n --no-progress overtrue/phplint
|
||||
|
||||
- name: PHP Lint
|
||||
if: ${{ ! cancelled() }}
|
||||
run: ./vendor/bin/phplint -n --exclude={^vendor/.*} -- .
|
||||
|
||||
- name: PHP CodeSniffer
|
||||
if: ${{ ! cancelled() }}
|
||||
run: phpcs
|
||||
|
||||
test:
|
||||
name: Unit tests with php ${{ matrix.php }} on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
env:
|
||||
phpunit-version: 8.5
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php: ['8.2', '8.3', '8.4']
|
||||
os: ['ubuntu-latest']
|
||||
|
||||
steps:
|
||||
- name: Checkout code base
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
tools: phpunit:${{ matrix.phpunit-version || env.phpunit-version }}
|
||||
|
||||
- name: Setup Icinga Web
|
||||
run: |
|
||||
git clone --depth 1 https://github.com/Icinga/icingaweb2.git _icingaweb2
|
||||
ln -s `pwd` _icingaweb2/modules/businessprocess
|
||||
|
||||
- name: Setup Libraries
|
||||
run: |
|
||||
mkdir _libraries
|
||||
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git _libraries/ipl
|
||||
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git _libraries/vendor
|
||||
|
||||
- name: Setup dependencies
|
||||
run: composer require -d _icingaweb2 -n --no-progress mockery/mockery
|
||||
|
||||
- name: PHPUnit
|
||||
env:
|
||||
ICINGAWEB_LIBDIR: _libraries
|
||||
ICINGAWEB_CONFIGDIR: test/config
|
||||
run: phpunit --verbose --bootstrap _icingaweb2/test/php/bootstrap.php
|
||||
php:
|
||||
name: PHP
|
||||
uses: Icinga/github-actions/.github/workflows/php.yml@main
|
||||
with:
|
||||
php-extensions: ldap
|
||||
dependencies: |
|
||||
{
|
||||
"./vendor/icingaweb2-modules/director" : "https://github.com/Icinga/icingaweb2-module-director.git",
|
||||
"./vendor/icingaweb2-modules/icingadb" : "https://github.com/Icinga/icingadb-web.git"
|
||||
}
|
||||
env: |
|
||||
{
|
||||
"ICINGAWEB_CONFIGDIR" : "./test/config"
|
||||
}
|
||||
|
|
|
|||
17
.github/workflows/phpstan.yml
vendored
17
.github/workflows/phpstan.yml
vendored
|
|
@ -1,17 +0,0 @@
|
|||
name: PHPStan
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
phpstan:
|
||||
uses: icinga/github-actions/.github/workflows/phpstan.yml@main
|
||||
with:
|
||||
dependencies: |
|
||||
{
|
||||
"/icingaweb2" : "https://github.com/Icinga/icingaweb2.git",
|
||||
"/usr/share/icingaweb2-modules/icingadb" : "https://github.com/Icinga/icingadb-web.git",
|
||||
"/usr/share/icingaweb2-modules/director" : "https://github.com/Icinga/icingaweb2-module-director.git"
|
||||
}
|
||||
|
|
@ -59,7 +59,8 @@ class CleanupCommand extends Command
|
|||
continue;
|
||||
}
|
||||
|
||||
if (Module::exists('icingadb')
|
||||
if (
|
||||
Module::exists('icingadb')
|
||||
&& (! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())
|
||||
) {
|
||||
IcingaDbState::apply($bp);
|
||||
|
|
|
|||
|
|
@ -136,7 +136,8 @@ class ProcessCommand extends Command
|
|||
try {
|
||||
/** @var BpNode $node */
|
||||
$node = $bp->getNode($nodeName);
|
||||
if (Module::exists('icingadb')
|
||||
if (
|
||||
Module::exists('icingadb')
|
||||
&& (! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())
|
||||
) {
|
||||
IcingaDbState::apply($bp);
|
||||
|
|
|
|||
|
|
@ -95,7 +95,8 @@ class NodeController extends Controller
|
|||
continue;
|
||||
}
|
||||
|
||||
if (Module::exists('icingadb') &&
|
||||
if (
|
||||
Module::exists('icingadb') &&
|
||||
(! $config->getBackendName() && IcingadbSupport::useIcingaDbAsBackend())
|
||||
) {
|
||||
IcingaDbState::apply($config);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,8 @@ class ProcessController extends Controller
|
|||
$bp = $this->loadModifiedBpConfig();
|
||||
$node = $this->getNode($bp);
|
||||
|
||||
if (Module::exists('icingadb') &&
|
||||
if (
|
||||
Module::exists('icingadb') &&
|
||||
(! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())
|
||||
) {
|
||||
IcingaDbState::apply($bp);
|
||||
|
|
@ -704,7 +705,7 @@ class ProcessController extends Controller
|
|||
|
||||
$tabs = $this->tabs()->add('config', array(
|
||||
'label' => $this->translate('Process Configuration'),
|
||||
'url' =>Url::fromPath('businessprocess/process/config', $params)
|
||||
'url' => Url::fromPath('businessprocess/process/config', $params)
|
||||
));
|
||||
|
||||
if ($this->params->get('showDiff')) {
|
||||
|
|
@ -713,7 +714,7 @@ class ProcessController extends Controller
|
|||
|
||||
$tabs->add('source', array(
|
||||
'label' => $this->translate('Source'),
|
||||
'url' =>Url::fromPath('businessprocess/process/source', $params)
|
||||
'url' => Url::fromPath('businessprocess/process/source', $params)
|
||||
));
|
||||
|
||||
return $tabs;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class ServiceController extends Controller
|
|||
} else {
|
||||
$hostName = $this->params->get('host');
|
||||
$serviceName = $this->params->get('service');
|
||||
|
||||
|
||||
$query = $this->backend->select()
|
||||
->from('servicestatus', array('service_description'))
|
||||
->where('host_name', $hostName)
|
||||
|
|
|
|||
|
|
@ -84,7 +84,8 @@ class SuggestionsController extends Controller
|
|||
$search = "@$config:$search";
|
||||
}
|
||||
|
||||
if (in_array($search, $suggestions->getExcludeTerms(), true)
|
||||
if (
|
||||
in_array($search, $suggestions->getExcludeTerms(), true)
|
||||
|| isset($ignoreList[$search])
|
||||
|| ($forParent
|
||||
? $forParent->hasChild($search)
|
||||
|
|
@ -94,7 +95,8 @@ class SuggestionsController extends Controller
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($suggestions->matchSearch($bpNode->getName())
|
||||
if (
|
||||
$suggestions->matchSearch($bpNode->getName())
|
||||
|| (! $bpNode->hasAlias() || $suggestions->matchSearch($bpNode->getAlias()))
|
||||
|| $bpNode->getName() === $suggestions->getOriginalSearchValue()
|
||||
|| $bpNode->getAlias() === $suggestions->getOriginalSearchValue()
|
||||
|
|
|
|||
|
|
@ -204,8 +204,10 @@ class BpConfigForm extends BpConfigBaseForm
|
|||
}
|
||||
$meta = $config->getMetadata();
|
||||
foreach ($this->getValues() as $key => $value) {
|
||||
if (! in_array($key, ['Title', 'Description', 'Backend'], true)
|
||||
&& ($value === null || $value === '')) {
|
||||
if (
|
||||
! in_array($key, ['Title', 'Description', 'Backend'], true)
|
||||
&& ($value === null || $value === '')
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
<?php
|
||||
|
||||
// Avoid complaints about missing namespace and invalid class name
|
||||
// @codingStandardsIgnoreStart
|
||||
class Zend_View_Helper_FormSimpleNote extends Zend_View_Helper_FormElement
|
||||
class Zend_View_Helper_FormSimpleNote extends Zend_View_Helper_FormElement // phpcs:ignore
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
public function formSimpleNote($name, $value = null)
|
||||
{
|
||||
$info = $this->_getInfo($name, $value);
|
||||
|
|
|
|||
|
|
@ -2,17 +2,16 @@
|
|||
|
||||
/**
|
||||
* @deprecated
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
class Zend_View_Helper_RenderStateBadges extends Zend_View_Helper_Abstract
|
||||
class Zend_View_Helper_RenderStateBadges extends Zend_View_Helper_Abstract // phpcs:ignore
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
public function renderStateBadges($summary)
|
||||
{
|
||||
$html = '';
|
||||
|
||||
foreach ($summary as $state => $cnt) {
|
||||
if ($cnt === 0
|
||||
if (
|
||||
$cnt === 0
|
||||
|| $state === 'OK'
|
||||
|| $state === 'UP'
|
||||
) {
|
||||
|
|
@ -23,7 +22,7 @@ class Zend_View_Helper_RenderStateBadges extends Zend_View_Helper_Abstract
|
|||
. '" title="' . mt('monitoring', $state) . '">'
|
||||
. $cnt . '</span>';
|
||||
}
|
||||
|
||||
|
||||
if ($html !== '') {
|
||||
$html = '<div class="badges">' . $html . '</div>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ use ipl\Sql\Connection as IcingaDbConnection;
|
|||
|
||||
class BpConfig
|
||||
{
|
||||
const SOFT_STATE = 0;
|
||||
public const SOFT_STATE = 0;
|
||||
|
||||
const HARD_STATE = 1;
|
||||
public const HARD_STATE = 1;
|
||||
|
||||
/**
|
||||
* Name of the configured monitoring backend
|
||||
|
|
@ -295,8 +295,10 @@ class BpConfig
|
|||
public function getBackend()
|
||||
{
|
||||
if ($this->backend === null) {
|
||||
if (Module::exists('icingadb')
|
||||
&& (! $this->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())) {
|
||||
if (
|
||||
Module::exists('icingadb')
|
||||
&& (! $this->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())
|
||||
) {
|
||||
$this->backend = IcingaDbObject::fetchDb();
|
||||
} else {
|
||||
$this->backend = MonitoringBackend::instance(
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ use ipl\Web\Widget\Icon;
|
|||
|
||||
class BpNode extends Node
|
||||
{
|
||||
const OP_AND = '&';
|
||||
const OP_OR = '|';
|
||||
const OP_XOR = '^';
|
||||
const OP_NOT = '!';
|
||||
const OP_DEGRADED = '%';
|
||||
public const OP_AND = '&';
|
||||
public const OP_OR = '|';
|
||||
public const OP_XOR = '^';
|
||||
public const OP_NOT = '!';
|
||||
public const OP_DEGRADED = '%';
|
||||
|
||||
protected $operator = '&';
|
||||
|
||||
|
|
@ -261,7 +261,7 @@ class BpNode extends Node
|
|||
if ($child instanceof MonitoredNode) {
|
||||
$empty = false;
|
||||
break;
|
||||
} elseif (!$child->isEmpty()) {
|
||||
} elseif (! $child->isEmpty()) {
|
||||
$empty = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -561,7 +561,7 @@ class BpNode extends Node
|
|||
public function hasChildren($filter = null)
|
||||
{
|
||||
$childNames = $this->getChildNames();
|
||||
return !empty($childNames);
|
||||
return ! empty($childNames);
|
||||
}
|
||||
|
||||
public function getChildNames()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
// Icinga Business Process Modelling | (c) 2023 Icinga GmbH | GPLv2
|
||||
|
||||
namespace Icinga\Module\Businessprocess\Common;
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class IcingaDbObject
|
|||
|
||||
public static function applyIcingaDbRestrictions($query)
|
||||
{
|
||||
$object = new self;
|
||||
$object = new self();
|
||||
$object->applyRestrictions($query);
|
||||
|
||||
return $object;
|
||||
|
|
@ -88,7 +88,7 @@ class IcingaDbObject
|
|||
|
||||
public static function fetchDb()
|
||||
{
|
||||
$object = new self;
|
||||
$object = new self();
|
||||
return $object->getDb();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class NodeCreateAction extends NodeAction
|
|||
}
|
||||
|
||||
$parent = $this->getParentName();
|
||||
if ($parent !== null && !$config->hasBpNode($parent)) {
|
||||
if ($parent !== null && ! $config->hasBpNode($parent)) {
|
||||
$this->error('Parent process "%s" missing', $parent);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class NodeRemoveAction extends NodeAction
|
|||
$name = $this->getNodeName();
|
||||
$parent = $this->getParentName();
|
||||
if ($parent === null) {
|
||||
if (!$config->hasNode($name)) {
|
||||
if (! $config->hasNode($name)) {
|
||||
$this->error('Toplevel process "%s" not found', $name);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ trait CustomVarJoinTemplateOverride
|
|||
$this->customVars[strtolower($customvar)] = $alias;
|
||||
|
||||
if ($type === 'host') {
|
||||
if ($this instanceof ServicecommentQuery
|
||||
if (
|
||||
$this instanceof ServicecommentQuery
|
||||
|| $this instanceof ServicedowntimeQuery
|
||||
|| $this instanceof ServicecommenthistoryQuery
|
||||
|| $this instanceof ServicedowntimestarthistoryQuery
|
||||
|
|
|
|||
|
|
@ -8,21 +8,21 @@ use ipl\Web\Widget\Icon;
|
|||
|
||||
abstract class Node
|
||||
{
|
||||
const FLAG_DOWNTIME = 1;
|
||||
const FLAG_ACK = 2;
|
||||
const FLAG_MISSING = 4;
|
||||
const FLAG_NONE = 8;
|
||||
const SHIFT_FLAGS = 4;
|
||||
public const FLAG_DOWNTIME = 1;
|
||||
public const FLAG_ACK = 2;
|
||||
public const FLAG_MISSING = 4;
|
||||
public const FLAG_NONE = 8;
|
||||
public const SHIFT_FLAGS = 4;
|
||||
|
||||
const ICINGA_OK = 0;
|
||||
const ICINGA_WARNING = 1;
|
||||
const ICINGA_CRITICAL = 2;
|
||||
const ICINGA_UNKNOWN = 3;
|
||||
const ICINGA_UP = 0;
|
||||
const ICINGA_DOWN = 1;
|
||||
const ICINGA_UNREACHABLE = 2;
|
||||
const ICINGA_PENDING = 99;
|
||||
const NODE_EMPTY = 128;
|
||||
public const ICINGA_OK = 0;
|
||||
public const ICINGA_WARNING = 1;
|
||||
public const ICINGA_CRITICAL = 2;
|
||||
public const ICINGA_UNKNOWN = 3;
|
||||
public const ICINGA_UP = 0;
|
||||
public const ICINGA_DOWN = 1;
|
||||
public const ICINGA_UNREACHABLE = 2;
|
||||
public const ICINGA_PENDING = 99;
|
||||
public const NODE_EMPTY = 128;
|
||||
|
||||
/** @var bool Whether to treat acknowledged hosts/services always as UP/OK */
|
||||
protected static $ackIsOk = false;
|
||||
|
|
|
|||
|
|
@ -6,5 +6,4 @@ use Icinga\Module\Icingadb\Hook\IcingadbSupportHook;
|
|||
|
||||
class IcingadbSupport extends IcingadbSupportHook
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,8 @@ class ServiceDetailExtension extends ServiceDetailExtensionHook
|
|||
|
||||
public function getHtmlForObject(Service $service): ValidHtml
|
||||
{
|
||||
if (! isset($this->storage)
|
||||
if (
|
||||
! isset($this->storage)
|
||||
|| $service->checkcommand_name !== $this->commandName
|
||||
) {
|
||||
return HtmlString::create('');
|
||||
|
|
|
|||
|
|
@ -69,7 +69,8 @@ class DetailviewExtension extends DetailviewExtensionHook
|
|||
*/
|
||||
public function getHtmlForObject(MonitoredObject $object)
|
||||
{
|
||||
if (! isset($this->storage)
|
||||
if (
|
||||
! isset($this->storage)
|
||||
|| ! $object instanceof Service
|
||||
|| $object->check_command !== $this->commandName
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class Breadcrumb extends BaseHtmlElement
|
|||
public static function create(Renderer $renderer)
|
||||
{
|
||||
$bp = $renderer->getBusinessProcess();
|
||||
$breadcrumb = new static;
|
||||
$breadcrumb = new static();
|
||||
$bpUrl = $renderer->getBaseUrl();
|
||||
if ($bpUrl->getParam('action') === 'delete') {
|
||||
$bpUrl->remove('action');
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ abstract class Renderer extends HtmlDocument
|
|||
$this->createBadge($summary, 'PENDING')
|
||||
]);
|
||||
|
||||
if (!empty($elements)) {
|
||||
if (! empty($elements)) {
|
||||
$container = Html::tag('ul', ['class' => 'state-badges']);
|
||||
$container->add($itemCount);
|
||||
foreach ($elements as $element) {
|
||||
|
|
|
|||
|
|
@ -107,7 +107,8 @@ class NodeTile extends BaseHtmlElement
|
|||
$this->add(new Link($node->getAlias(), $this->getMainNodeUrl($node)->getAbsoluteUrl()));
|
||||
}
|
||||
|
||||
if ($this->renderer->rendersSubNode()
|
||||
if (
|
||||
$this->renderer->rendersSubNode()
|
||||
&& $this->renderer->getParentNode()->getChildState($node) !== $node->getState()
|
||||
) {
|
||||
$this->add(
|
||||
|
|
@ -122,7 +123,7 @@ class NodeTile extends BaseHtmlElement
|
|||
);
|
||||
}
|
||||
|
||||
if ($node instanceof BpNode && !$renderer->isBreadcrumb()) {
|
||||
if ($node instanceof BpNode && ! $renderer->isBreadcrumb()) {
|
||||
$this->add($renderer->renderStateBadges($node->getStateSummary(), $node->countChildren()));
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +145,8 @@ class NodeTile extends BaseHtmlElement
|
|||
$url = $this->renderer->getBaseUrl();
|
||||
|
||||
$p = $url->getParams();
|
||||
if ($node instanceof ImportedNode
|
||||
if (
|
||||
$node instanceof ImportedNode
|
||||
&& $this->renderer->getBusinessProcess()->getName() === $node->getBpConfig()->getName()
|
||||
) {
|
||||
$p->set('node', $node->getNodeName());
|
||||
|
|
@ -304,7 +306,8 @@ class NodeTile extends BaseHtmlElement
|
|||
));
|
||||
}
|
||||
|
||||
if ($this->renderer->getBusinessProcess()->getMetadata()->canModify()
|
||||
if (
|
||||
$this->renderer->getBusinessProcess()->getMetadata()->canModify()
|
||||
&& $this->node->getBpConfig()->getName() === $this->renderer->getBusinessProcess()->getName()
|
||||
&& $this->node->getName() !== '__unbound__'
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use ipl\Web\Widget\StateBall;
|
|||
|
||||
class TreeRenderer extends Renderer
|
||||
{
|
||||
const NEW_COLLAPSIBLE_IMPLEMENTATION_SINCE = '2.11.2';
|
||||
public const NEW_COLLAPSIBLE_IMPLEMENTATION_SINCE = '2.11.2';
|
||||
|
||||
public function assemble()
|
||||
{
|
||||
|
|
@ -229,7 +229,7 @@ class TreeRenderer extends Renderer
|
|||
}
|
||||
|
||||
$differentConfig = $node->getBpConfig()->getName() !== $this->getBusinessProcess()->getName();
|
||||
if (! $this->isLocked() && !$differentConfig) {
|
||||
if (! $this->isLocked() && ! $differentConfig) {
|
||||
$summary->add($this->getActionIcons($bp, $node));
|
||||
} elseif ($differentConfig) {
|
||||
$summary->add($this->actionIcon(
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use Icinga\Web\Session\SessionNamespace;
|
|||
|
||||
class Simulation
|
||||
{
|
||||
const DEFAULT_SESSION_KEY = 'bp-simulations';
|
||||
public const DEFAULT_SESSION_KEY = 'bp-simulations';
|
||||
|
||||
/**
|
||||
* @var SessionNamespace
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
<?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('ipl', $basedir . '/vendor/ipl')
|
||||
->loadModule('businessprocess', $basedir);
|
||||
}
|
||||
}
|
||||
|
|
@ -109,7 +109,8 @@ class Dashboard extends BaseHtmlElement
|
|||
continue;
|
||||
}
|
||||
|
||||
if (Module::exists('icingadb') &&
|
||||
if (
|
||||
Module::exists('icingadb') &&
|
||||
(! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())
|
||||
) {
|
||||
IcingaDbState::apply($bp);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,8 @@ class DashboardFullscreen extends BaseHtmlElement
|
|||
continue;
|
||||
}
|
||||
|
||||
if (Module::exists('icingadb') &&
|
||||
if (
|
||||
Module::exists('icingadb') &&
|
||||
(! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())
|
||||
) {
|
||||
IcingaDbState::apply($bp);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class CsrfToken
|
|||
|
||||
list($seed, $token) = explode('|', $token);
|
||||
|
||||
if (!is_numeric($seed)) {
|
||||
if (! is_numeric($seed)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,5 +4,4 @@ namespace Icinga\Module\Businessprocess\Web\Form\Element;
|
|||
|
||||
class Checkbox extends \Icinga\Web\Form\Element\Checkbox
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,11 @@ class SimpleNote extends FormElement
|
|||
|
||||
/**
|
||||
* Always ignore this element
|
||||
* @codingStandardsIgnoreStart
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_ignore = true;
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
protected $_ignore = true; // phpcs:ignore
|
||||
|
||||
public function isValid($value, $context = null)
|
||||
{
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ abstract class QuickBaseForm extends Zend_Form implements ValidHtml
|
|||
$this->setDefault($name, $value);
|
||||
$el->setValue($value);
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ use Exception;
|
|||
*/
|
||||
abstract class QuickForm extends QuickBaseForm
|
||||
{
|
||||
const ID = '__FORM_NAME';
|
||||
public const ID = '__FORM_NAME';
|
||||
|
||||
const CSRF = '__FORM_CSRF';
|
||||
public const CSRF = '__FORM_CSRF';
|
||||
|
||||
/**
|
||||
* The name of this form
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ class ProcessProblemsBadge extends BadgeNavigationItemRenderer
|
|||
$bp = $storage->loadProcess($this->getBpConfigName());
|
||||
foreach ($bp->getRootNodes() as $rootNode) {
|
||||
$nodeState = $rootNode->getState();
|
||||
if (! $rootNode->isEmpty() &&
|
||||
if (
|
||||
! $rootNode->isEmpty() &&
|
||||
! in_array($nodeState, [Node::ICINGA_OK, Node::ICINGA_PENDING], true)
|
||||
) {
|
||||
if ($nodeState === $state) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ class ProcessesProblemsBadge extends BadgeNavigationItemRenderer
|
|||
|
||||
foreach ($storage->listProcessNames() as $processName) {
|
||||
$bp = $storage->loadProcess($processName);
|
||||
if (Module::exists('icingadb') &&
|
||||
if (
|
||||
Module::exists('icingadb') &&
|
||||
(! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())
|
||||
) {
|
||||
IcingaDbState::apply($bp);
|
||||
|
|
@ -42,7 +43,8 @@ class ProcessesProblemsBadge extends BadgeNavigationItemRenderer
|
|||
|
||||
foreach ($bp->getRootNodes() as $rootNode) {
|
||||
$nodeState = $rootNode->getState();
|
||||
if (! $rootNode->isEmpty() &&
|
||||
if (
|
||||
! $rootNode->isEmpty() &&
|
||||
! in_array($nodeState, [Node::ICINGA_OK, Node::ICINGA_PENDING], true)
|
||||
) {
|
||||
if ($nodeState === $state) {
|
||||
|
|
|
|||
25
phpcs.xml
25
phpcs.xml
|
|
@ -1,25 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset name="PHP_CodeSniffer">
|
||||
<description>Sniff our code a while</description>
|
||||
|
||||
<file>configuration.php</file>
|
||||
<file>run.php</file>
|
||||
<file>application/</file>
|
||||
<file>library/</file>
|
||||
<file>test/</file>
|
||||
|
||||
<exclude-pattern>vendor/*</exclude-pattern>
|
||||
|
||||
<arg value="wps"/>
|
||||
<arg name="colors"/>
|
||||
<arg name="report-width" value="auto"/>
|
||||
<arg name="report-full"/>
|
||||
<arg name="report-gitblame"/>
|
||||
<arg name="report-summary"/>
|
||||
<arg name="encoding" value="UTF-8"/>
|
||||
|
||||
<rule ref="PSR2"/>
|
||||
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
|
||||
<exclude-pattern>library/Businessprocess/Web/Form/Element/Multiselect.php</exclude-pattern>
|
||||
</rule>
|
||||
</ruleset>
|
||||
28
phpunit.xml
28
phpunit.xml
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="test/bootstrap.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Businessprocess PHP Unit tests">
|
||||
<directory suffix=".php">test/php</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">library/Businessprocess</directory>
|
||||
<exclude>
|
||||
<directory suffix=".php">library/Businessprocess/Director</directory>
|
||||
</exclude>
|
||||
<exclude>
|
||||
<directory suffix=".php">library/Businessprocess/ProvidedHook</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Icinga\Module\Businessprocess\Test\Bootstrap;
|
||||
|
||||
call_user_func(function () {
|
||||
$basedir = dirname(__DIR__);
|
||||
if (! class_exists('PHPUnit_Framework_TestCase')) {
|
||||
require_once __DIR__ . '/phpunit-compat.php';
|
||||
}
|
||||
|
||||
$include_path = $basedir . '/vendor' . PATH_SEPARATOR . ini_get('include_path');
|
||||
ini_set('include_path', $include_path);
|
||||
|
||||
require_once $basedir . '/library/Businessprocess/Test/Bootstrap.php';
|
||||
Bootstrap::cli($basedir);
|
||||
});
|
||||
|
|
@ -15,7 +15,7 @@ class MinOperatorTest extends BaseTestCase
|
|||
'a = 1 of: b;c',
|
||||
'a = 2 of: b;c + c;d + d;e',
|
||||
);
|
||||
$this->getName();
|
||||
|
||||
foreach ($expressions as $expression) {
|
||||
$this->assertInstanceOf(
|
||||
'Icinga\\Module\\Businessprocess\\BpConfig',
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
class PHPUnit_Framework_TestCase extends TestCase
|
||||
{
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
MODULE_HOME=${MODULE_HOME:="$(dirname "$(readlink -f $(dirname "$0"))")"}
|
||||
PHP_VERSION="$(php -r 'echo phpversion();')"
|
||||
|
||||
# see also .travis.yml
|
||||
ICINGAWEB_VERSION=${ICINGAWEB_VERSION:=2.5.1}
|
||||
ICINGAWEB_GITREF=${ICINGAWEB_GITREF:=}
|
||||
|
||||
IPL_VERSION=${IPL_VERSION:=0.1.1}
|
||||
|
||||
PHPCS_VERSION=${PHPCS_VERSION:=2.9.1}
|
||||
|
||||
if [ "$PHP_VERSION" '<' 5.6.0 ]; then
|
||||
PHPUNIT_VERSION=${PHPUNIT_VERSION:=4.8}
|
||||
else
|
||||
PHPUNIT_VERSION=${PHPUNIT_VERSION:=5.7}
|
||||
fi
|
||||
|
||||
cd ${MODULE_HOME}
|
||||
|
||||
test -d vendor || mkdir vendor
|
||||
cd vendor/
|
||||
|
||||
# icingaweb2
|
||||
if [ -n "$ICINGAWEB_GITREF" ]; then
|
||||
icingaweb_path="icingaweb2"
|
||||
test ! -L "$icingaweb_path" || rm "$icingaweb_path"
|
||||
|
||||
if [ ! -d "$icingaweb_path" ]; then
|
||||
git clone https://github.com/Icinga/icingaweb2.git "$icingaweb_path"
|
||||
fi
|
||||
|
||||
(
|
||||
set -e
|
||||
cd "$icingaweb_path"
|
||||
git fetch -p
|
||||
git checkout -f "$ICINGAWEB_GITREF"
|
||||
)
|
||||
else
|
||||
icingaweb_path="icingaweb2-${ICINGAWEB_VERSION}"
|
||||
if [ ! -e "${icingaweb_path}".tar.gz ]; then
|
||||
wget -O "${icingaweb_path}".tar.gz https://github.com/Icinga/icingaweb2/archive/v"${ICINGAWEB_VERSION}".tar.gz
|
||||
fi
|
||||
if [ ! -d "${icingaweb_path}" ]; then
|
||||
tar xf "${icingaweb_path}".tar.gz
|
||||
fi
|
||||
|
||||
rm -f icingaweb2
|
||||
ln -svf "${icingaweb_path}" icingaweb2
|
||||
fi
|
||||
ln -svf "${icingaweb_path}"/library/Icinga
|
||||
ln -svf "${icingaweb_path}"/library/vendor/Zend
|
||||
|
||||
# ipl
|
||||
ipl_path="ipl"
|
||||
if [ ! -d "$ipl_path" ]; then
|
||||
git clone https://github.com/Icinga/icingaweb2-module-ipl.git "$ipl_path"
|
||||
fi
|
||||
(
|
||||
set -e
|
||||
cd "$ipl_path"
|
||||
git fetch -p
|
||||
git checkout -f "stable/$IPL_VERSION"
|
||||
)
|
||||
|
||||
# phpunit
|
||||
phpunit_path="phpunit-${PHPUNIT_VERSION}"
|
||||
if [ ! -e "${phpunit_path}".phar ]; then
|
||||
wget -O "${phpunit_path}".phar https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar
|
||||
fi
|
||||
ln -svf "${phpunit_path}".phar phpunit.phar
|
||||
|
||||
# phpcs
|
||||
phpcs_path="phpcs-${PHPCS_VERSION}"
|
||||
if [ ! -e "${phpcs_path}".phar ]; then
|
||||
wget -O "${phpcs_path}".phar \
|
||||
https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${PHPCS_VERSION}/phpcs.phar
|
||||
fi
|
||||
ln -svf "${phpcs_path}".phar phpcs.phar
|
||||
Loading…
Reference in a new issue