Skip to content

Commit

Permalink
Use instance of SearchHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu authored and OskarStark committed Dec 15, 2020
1 parent 035ecab commit 2dd7abf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 5 additions & 2 deletions tests/Action/SearchActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function setUp(): void
]);

$this->breadcrumbsBuilder = $this->createMock(BreadcrumbsBuilderInterface::class);
$this->searchHandler = $this->createMock(SearchHandler::class);
$this->searchHandler = new SearchHandler(true);
$this->twig = $this->createStub(Environment::class);

$this->action = new SearchAction(
Expand Down Expand Up @@ -74,7 +74,10 @@ public function testGlobalPage(): void

public function testAjaxCall(): void
{
$admin = new CleanAdmin('code', 'class', 'controller');
$adminCode = 'code';

$this->searchHandler->configureAdminSearch([$adminCode => false]);
$admin = new CleanAdmin($adminCode, 'class', 'controller');
$this->container->set('foo', $admin);
$this->pool->setAdminServiceIds(['foo']);
$request = new Request(['admin' => 'foo']);
Expand Down
9 changes: 7 additions & 2 deletions tests/Block/AdminSearchBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function setUp(): void
parent::setUp();

$this->pool = $this->createMock(Pool::class);
$this->searchHandler = $this->createMock(SearchHandler::class);
$this->searchHandler = new SearchHandler(true);
}

public function testDefaultSettings(): void
Expand Down Expand Up @@ -93,7 +93,12 @@ public function testDefaultSettingsWithoutEmptyBoxOption(): void

public function testGlobalSearchReturnsEmptyWhenFiltersAreDisabled(): void
{
$adminCode = 'code';

$admin = $this->createMock(AbstractAdmin::class);
$admin
->method('getCode')
->willReturn($adminCode);

$blockService = new AdminSearchBlockService(
$this->createMock(Environment::class),
Expand All @@ -103,7 +108,7 @@ public function testGlobalSearchReturnsEmptyWhenFiltersAreDisabled(): void
);
$blockContext = $this->getBlockContext($blockService);

$this->searchHandler->expects(self::once())->method('search')->willReturn(false);
$this->searchHandler->configureAdminSearch([$adminCode => false]);
$this->pool->expects(self::once())->method('getAdminByAdminCode')->willReturn($admin);
$admin->expects(self::once())->method('checkAccess')->with('list')->willReturn(true);

Expand Down

0 comments on commit 2dd7abf

Please sign in to comment.