diff --git a/tests/Action/SearchActionTest.php b/tests/Action/SearchActionTest.php index 1d39b985f1..7a7ee2c260 100644 --- a/tests/Action/SearchActionTest.php +++ b/tests/Action/SearchActionTest.php @@ -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( @@ -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']); diff --git a/tests/Block/AdminSearchBlockServiceTest.php b/tests/Block/AdminSearchBlockServiceTest.php index 129443a7e6..697de36aa1 100644 --- a/tests/Block/AdminSearchBlockServiceTest.php +++ b/tests/Block/AdminSearchBlockServiceTest.php @@ -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 @@ -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), @@ -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);