diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchFacetsTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchFacetsTest.php index d4b40c76be5..773e9ec788f 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchFacetsTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchFacetsTest.php @@ -1381,32 +1381,37 @@ protected function assertNoResetFiltersButton(Element $page): void public static function multiSelectOnAdvancedSearchProvider(): array { return [ - 'with language switch' => [true], - 'without language switch' => [false], + 'with language switch / with checkbox' => [true, true], + 'without language switch / with checkbox' => [false, true], + 'with language switch / without checkbox' => [true, false], + 'without language switch / without checkbox' => [false, false], ]; } /** * Test applying multi-facet selection to advanced search results, with or without changing the - * language setting first. + * language setting first and/or including a pre-existing checkbox filter. * - * @param bool $changeLanguage Should we change the language before applying the facets? + * @param bool $changeLanguage Should we change the language before applying the facets? + * @param bool $includeCheckbox Should we apply a checkbox prior to multi-selection? * * @dataProvider multiSelectOnAdvancedSearchProvider * * @return void */ - public function testMultiSelectOnAdvancedSearch(bool $changeLanguage): void + public function testMultiSelectOnAdvancedSearch(bool $changeLanguage, bool $includeCheckbox): void { - $this->changeConfigs( - [ - 'facets' => [ - 'Results_Settings' => [ - 'multiFacetsSelection' => true, - ], - ], - ] - ); + $facets = [ + 'Results_Settings' => [ + 'multiFacetsSelection' => true, + ], + ]; + if ($includeCheckbox) { + // Create a pointless checkbox filter that will not impact the result set size + // (we're just testing that it applies to the URL correctly): + $facets['CheckboxFacets']['title:*'] = 'Has Title'; + } + $this->changeConfigs(compact('facets')); $path = '/Search/Advanced'; $session = $this->getMinkSession(); $session->visit($this->getVuFindUrl() . $path); @@ -1416,11 +1421,17 @@ public function testMultiSelectOnAdvancedSearch(bool $changeLanguage): void $this->findCssAndSetValue($page, '#search_lookfor0_1', 'history'); $this->findCss($page, '[type=submit]')->press(); + if ($includeCheckbox) { + $link = $this->findAndAssertLink($page, 'Has Title'); + $link->click(); + $this->waitForPageLoad($page); + } + if ($changeLanguage) { $this->flipflopLanguage($page); } - // Activate the first two facet values: + // Activate the first two facet values (and the checkbox filter, if requested): $this->clickCss($page, '.js-user-selection-multi-filters'); $this->clickCss($page, '.facet__list__item a'); $this->clickCss($page, '.facet__list__item a', index: 1); @@ -1433,7 +1444,12 @@ public function testMultiSelectOnAdvancedSearch(bool $changeLanguage): void $this->findCssAndGetText($page, '.adv_search_terms strong') ); + // Make sure we have the expected number of filters applied: $this->assertCount(2, $page->findAll('css', '.facet.active')); + $query = parse_url($session->getCurrentUrl(), PHP_URL_QUERY); + parse_str($query, $queryArray); + $expectedFilterCount = $includeCheckbox ? 3 : 2; + $this->assertCount($expectedFilterCount, $queryArray['filter']); // If configured, flip-flop language again to potentially modify filter params: if ($changeLanguage) {