From c9f3f0444dd7224713fae703682c51ea3fa679db Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 4 Jul 2023 16:22:08 +0200 Subject: [PATCH] tests: Require view helpers at runtime --- .../views/helpers/MonitoringFlagsTest.php | 13 +++++++++++-- .../views/helpers/PluginOutputTest.php | 8 ++++++-- .../php/library/Monitoring/Object/MacroTest.php | 2 -- .../ScrollingStyle/SlidingWithBorderTest.php | 15 ++++++++++++--- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/modules/monitoring/test/php/application/views/helpers/MonitoringFlagsTest.php b/modules/monitoring/test/php/application/views/helpers/MonitoringFlagsTest.php index d6e350eec..122d4f3d0 100644 --- a/modules/monitoring/test/php/application/views/helpers/MonitoringFlagsTest.php +++ b/modules/monitoring/test/php/application/views/helpers/MonitoringFlagsTest.php @@ -3,13 +3,22 @@ namespace Tests\Icinga\Module\Monitoring\Application\Views\Helpers; +use Icinga\Application\Icinga; use Zend_View_Helper_MonitoringFlags; use Icinga\Test\BaseTestCase; -require_once realpath(BaseTestCase::$moduleDir . '/monitoring/application/views/helpers/MonitoringFlags.php'); - class MonitoringFlagsTest extends BaseTestCase { + public function setUp(): void + { + parent::setUp(); + + require_once realpath( + Icinga::app()->getModuleManager()->getModuleDir('monitoring') + . '/application/views/helpers/MonitoringFlags.php' + ); + } + public function testHosts1() { $testArray = array( diff --git a/modules/monitoring/test/php/application/views/helpers/PluginOutputTest.php b/modules/monitoring/test/php/application/views/helpers/PluginOutputTest.php index e9d5f9091..9cda9f26d 100644 --- a/modules/monitoring/test/php/application/views/helpers/PluginOutputTest.php +++ b/modules/monitoring/test/php/application/views/helpers/PluginOutputTest.php @@ -3,12 +3,11 @@ namespace Tests\Icinga\Module\Monitoring\Application\Views\Helpers; +use Icinga\Application\Icinga; use Icinga\Web\View; use Zend_View_Helper_PluginOutput; use Icinga\Test\BaseTestCase; -require_once realpath(BaseTestCase::$moduleDir . '/monitoring/application/views/helpers/PluginOutput.php'); - class PluginOutputTest extends BaseTestCase { /** @var Zend_View_Helper_PluginOutput */ @@ -24,6 +23,11 @@ class PluginOutputTest extends BaseTestCase { parent::setUp(); + require_once realpath( + Icinga::app()->getModuleManager()->getModuleDir('monitoring') + . '/application/views/helpers/PluginOutput.php' + ); + $this->helper = $h = new Zend_View_Helper_PluginOutput; $h->setView(new View()); } diff --git a/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php b/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php index 2fe636728..59475114f 100644 --- a/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php +++ b/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php @@ -7,8 +7,6 @@ use Mockery; use Icinga\Test\BaseTestCase; use Icinga\Module\Monitoring\Object\Macro; -require_once realpath(BaseTestCase::$moduleDir . '/monitoring/library/Monitoring/Object/Macro.php'); - class MacroTest extends BaseTestCase { public function testHostMacros() diff --git a/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php b/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php index 96d2ec65c..a62a8bec0 100644 --- a/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php +++ b/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php @@ -3,14 +3,23 @@ namespace Tests\Icinga\Web\Paginator\ScrollingStyle; +use Icinga\Application\Icinga; use Mockery; use Zend_Paginator; use Icinga\Test\BaseTestCase; -require_once realpath(BaseTestCase::$libDir . '/Web/Paginator/ScrollingStyle/SlidingWithBorder.php'); - -class SlidingwithborderTest extends BaseTestCase +class SlidingWithborderTest extends BaseTestCase { + public function setUp(): void + { + parent::setUp(); + + require_once realpath( + Icinga::app()->getLibraryDir('Icinga') + . '/Web/Paginator/ScrollingStyle/SlidingWithBorder.php' + ); + } + public function testGetPages2() { $scrollingStyle = new \Icinga_Web_Paginator_ScrollingStyle_SlidingWithBorder();