tests: The app is soon not mocked anymore, so don't use it as such

This commit is contained in:
Johannes Meyer 2023-07-04 16:26:36 +02:00
parent e572652f4c
commit 776e0803fa
2 changed files with 6 additions and 18 deletions

View File

@ -42,7 +42,6 @@ class AuthenticationBackendReorderFormTest extends BaseTestCase
) )
); );
Icinga::app()->shouldReceive('getModuleManager->getLoadedModules')->andReturn([]);
$this->getRequestMock()->shouldReceive('getMethod')->andReturn('POST') $this->getRequestMock()->shouldReceive('getMethod')->andReturn('POST')
->shouldReceive('isPost')->andReturn(true) ->shouldReceive('isPost')->andReturn(true)
->shouldReceive('getPost')->andReturn(array('backend_newpos' => 'test3|1')); ->shouldReceive('getPost')->andReturn(array('backend_newpos' => 'test3|1'));

View File

@ -3,8 +3,8 @@
namespace Tests\Icinga\Web; namespace Tests\Icinga\Web;
use Icinga\Application\Icinga;
use Icinga\Authentication\Role; use Icinga\Authentication\Role;
use Mockery;
use Icinga\Test\BaseTestCase; use Icinga\Test\BaseTestCase;
use Icinga\User; use Icinga\User;
use Icinga\Web\Widget\SearchDashboard; use Icinga\Web\Widget\SearchDashboard;
@ -13,23 +13,12 @@ class SearchDashboardTest extends BaseTestCase
{ {
public function setUp(): void public function setUp(): void
{ {
$moduleMock = Mockery::mock('Icinga\Application\Modules\Module'); parent::setUp();
$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');
$moduleManagerMock = Mockery::mock('Icinga\Application\Modules\Manager'); Icinga::app()->getModuleManager()
$moduleManagerMock->shouldReceive('getLoadedModules')->andReturn(array( ->loadModule('test-module', '/tmp')
'test-module' => $moduleMock ->getModule('test-module')
)); ->provideSearchUrl('Hosts', 'monitoring/list/hosts?sort=host_severity&limit=10');
$bootstrapMock = $this->setupIcingaMock();
$bootstrapMock->shouldReceive('getModuleManager')->andReturn($moduleManagerMock);
} }
public function testWhetherRenderThrowsAnExceptionWhenHasNoDashlets() public function testWhetherRenderThrowsAnExceptionWhenHasNoDashlets()