Skip to content

Commit

Permalink
StateBadgesTest: Fix test and skip it without Icinga Web
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed Oct 17, 2023
1 parent 656c1dc commit 8bbb499
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions tests/StateBadgesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

namespace ipl\Tests\Web;

use Icinga\Web\UrlParams;
use ipl\Stdlib\Filter;
use ipl\Web\Common\StateBadges;
use ipl\Web\Filter\QueryString;
use ipl\Web\Url;

class StateBadgesTest extends TestCase
{
public function testCreateLinkRendersBaseFilterCorrectly()
{
if (! class_exists('\Icinga\Web\Url')) {
$this->markTestSkipped('Icinga Web is required to run this test');
}

$stateBadges = $this->createStateBadges()
->setBaseFilter(Filter::any(
Filter::equal('foo', 'bar'),
Expand All @@ -29,15 +33,10 @@ private function createStateBadges()
{
$queryString = null;

$urlMock = $this->createConfiguredMock(Url::class, [
'getBasePath' => 'test',
'getParams' => $this->createConfiguredMock(UrlParams::class, [
'toArray' => []
])
]);
$urlMock->method('setQueryString')->willReturnCallback(
function ($qs) use ($urlMock, &$queryString) {
$queryString = $qs;
$urlMock = $this->createMock(Url::class);
$urlMock->method('setFilter')->willReturnCallback(
function ($filter) use ($urlMock, &$queryString) {
$queryString = QueryString::render($filter);

return $urlMock;
}
Expand Down

0 comments on commit 8bbb499

Please sign in to comment.