diff --git a/module/VuFind/src/VuFind/Recommend/SideFacets.php b/module/VuFind/src/VuFind/Recommend/SideFacets.php index d1bd2b01741b8471a6832ed66d664ce5c0b9ab99..288fcfb91b9d45ff7104c9d36a8f8170ae07781e 100644 --- a/module/VuFind/src/VuFind/Recommend/SideFacets.php +++ b/module/VuFind/src/VuFind/Recommend/SideFacets.php @@ -123,7 +123,7 @@ class SideFacets extends AbstractFacets \VuFind\Config\PluginManager $configLoader, HierarchicalFacetHelper $facetHelper = null ) { - $this->configLoader = $configLoader; + parent::__construct($configLoader); $this->hierarchicalFacetHelper = $facetHelper; } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SideFacetsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SideFacetsTest.php index f09cc132e62a9723e44c719fc8a21ed8e21314e7..7028c0b1ebeffda28eefaf920ed009fcd7087abe 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SideFacetsTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SideFacetsTest.php @@ -99,6 +99,77 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase $sf->getFacetSet(); } + /** + * Test facet initialization. + * + * @return void + */ + public function testFacetInit() + { + $configLoader = $this->getMockConfigLoader( + array( + 'Results' => array( + 'format' => 'Format', + ), + 'Results_Settings' => array( + 'orFacets' => '*', // test or facet support + ), + 'Checkboxes' => array( + 'description' => 'filter', + ) + ) + ); + $results = $this->getMockResults(); + $params = $results->getParams(); + $params->expects($this->once())->method('addFacet')->with($this->equalTo('format'), $this->equalTo('Format'), $this->equalTo(true)); + $params->expects($this->once())->method('addCheckboxFacet')->with($this->equalTo('filter'), $this->equalTo('description')); + $this->getSideFacets($configLoader, $results, ':~Checkboxes'); // test ~ checkbox flip function + } + + /** + * Test getFacetOperator + * + * @return void + */ + public function testGetFacetOperator() + { + $this->assertEquals('AND', $this->getSideFacets()->getFacetOperator('format')); // default + $configLoader = $this->getMockConfigLoader( + array( + 'Results' => array( + 'format' => 'Format', + ), + 'Results_Settings' => array( + 'orFacets' => '*', // test or facet support + ), + ) + ); + $sf = $this->getSideFacets($configLoader); + $this->assertEquals('OR', $sf->getFacetOperator('format')); + } + + /** + * Test excludeAllowed + * + * @return void + */ + public function testExcludeAllowed() + { + $this->assertFalse($this->getSideFacets()->excludeAllowed('format')); // default + $configLoader = $this->getMockConfigLoader( + array( + 'Results' => array( + 'format' => 'Format', + ), + 'Results_Settings' => array( + 'exclude' => '*', // test or facet support + ), + ) + ); + $sf = $this->getSideFacets($configLoader); + $this->assertTrue($sf->excludeAllowed('format')); + } + /** * Test getVisibleFilters *