From 776e0803fa6f091fea82a5f1d370556f7f5be605 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 4 Jul 2023 16:26:36 +0200 Subject: [PATCH] tests: The app is soon not mocked anymore, so don't use it as such --- .../Config/UserBackendReorderFormTest.php | 1 - .../Icinga/Web/Widget/SearchDashboardTest.php | 23 +++++-------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/test/php/application/forms/Config/UserBackendReorderFormTest.php b/test/php/application/forms/Config/UserBackendReorderFormTest.php index f5f0f1544..deab3d336 100644 --- a/test/php/application/forms/Config/UserBackendReorderFormTest.php +++ b/test/php/application/forms/Config/UserBackendReorderFormTest.php @@ -42,7 +42,6 @@ class AuthenticationBackendReorderFormTest extends BaseTestCase ) ); - Icinga::app()->shouldReceive('getModuleManager->getLoadedModules')->andReturn([]); $this->getRequestMock()->shouldReceive('getMethod')->andReturn('POST') ->shouldReceive('isPost')->andReturn(true) ->shouldReceive('getPost')->andReturn(array('backend_newpos' => 'test3|1')); diff --git a/test/php/library/Icinga/Web/Widget/SearchDashboardTest.php b/test/php/library/Icinga/Web/Widget/SearchDashboardTest.php index 916ab7914..32b31f53e 100644 --- a/test/php/library/Icinga/Web/Widget/SearchDashboardTest.php +++ b/test/php/library/Icinga/Web/Widget/SearchDashboardTest.php @@ -3,8 +3,8 @@ namespace Tests\Icinga\Web; +use Icinga\Application\Icinga; use Icinga\Authentication\Role; -use Mockery; use Icinga\Test\BaseTestCase; use Icinga\User; use Icinga\Web\Widget\SearchDashboard; @@ -13,23 +13,12 @@ class SearchDashboardTest extends BaseTestCase { public function setUp(): void { - $moduleMock = Mockery::mock('Icinga\Application\Modules\Module'); - $searchUrl = (object) array( - 'title' => 'Hosts', - 'url' => 'monitoring/list/hosts?sort=host_severity&limit=10' - ); - $moduleMock->shouldReceive('getSearchUrls')->andReturn(array( - $searchUrl - )); - $moduleMock->shouldReceive('getName')->andReturn('test'); + parent::setUp(); - $moduleManagerMock = Mockery::mock('Icinga\Application\Modules\Manager'); - $moduleManagerMock->shouldReceive('getLoadedModules')->andReturn(array( - 'test-module' => $moduleMock - )); - - $bootstrapMock = $this->setupIcingaMock(); - $bootstrapMock->shouldReceive('getModuleManager')->andReturn($moduleManagerMock); + Icinga::app()->getModuleManager() + ->loadModule('test-module', '/tmp') + ->getModule('test-module') + ->provideSearchUrl('Hosts', 'monitoring/list/hosts?sort=host_severity&limit=10'); } public function testWhetherRenderThrowsAnExceptionWhenHasNoDashlets()