diff --git a/modules/facets_range_widget/tests/src/Unit/Plugin/widget/SliderWidgetTest.php b/modules/facets_range_widget/tests/src/Unit/Plugin/widget/SliderWidgetTest.php index df94c1f..3479404 100644 --- a/modules/facets_range_widget/tests/src/Unit/Plugin/widget/SliderWidgetTest.php +++ b/modules/facets_range_widget/tests/src/Unit/Plugin/widget/SliderWidgetTest.php @@ -31,7 +31,7 @@ public function setUp() { */ public function testGetQueryType() { $result = $this->widget->getQueryType($this->queryTypes); - $this->assertEquals('string', $result); + $this->assertEquals(NULL, $result); } /** diff --git a/src/Entity/Facet.php b/src/Entity/Facet.php index c90a2f0..330214f 100644 --- a/src/Entity/Facet.php +++ b/src/Entity/Facet.php @@ -490,7 +490,7 @@ public function getQueryType() { } // Invalid choice. - throw new InvalidQueryTypeException("Invalid query type combination in widget / processors. Widget: {$widgetQueryType}, Processors: " . array_keys($processorQueryTypes) . "."); + throw new InvalidQueryTypeException("Invalid query type combination in widget / processors. Widget: {$widgetQueryType}, Processors: " . implode(', ', array_keys($processorQueryTypes)) . "."); } /** @@ -503,6 +503,7 @@ public function getQueryType() { * * @return string * The class name of the chose query type. + * * @throws \Drupal\facets\Exception\InvalidQueryTypeException */ protected function pickQueryType(array $allTypes, $type) { diff --git a/src/Plugin/facets/query_type/SearchApiDate.php b/src/Plugin/facets/query_type/SearchApiDate.php index 1e0c769..21d64fd 100644 --- a/src/Plugin/facets/query_type/SearchApiDate.php +++ b/src/Plugin/facets/query_type/SearchApiDate.php @@ -406,7 +406,7 @@ protected function getGranularity() { * Retrieve configuration: If the date should be displayed relatively. * * @return bool - * Returns true if the display should be relative, false if it's absolute. + * Returns true if the display should be relative, false if it's absolute. */ protected function getDisplayRelative() { return $this->getConfiguration()['display_relative']; diff --git a/src/Processor/ProcessorInterface.php b/src/Processor/ProcessorInterface.php index 0617aed..a1b7ec5 100644 --- a/src/Processor/ProcessorInterface.php +++ b/src/Processor/ProcessorInterface.php @@ -114,9 +114,9 @@ public function getDescription(); /** * Picks the preferred query type for this widget. * - * @return string|NULL + * @return string|null * The query type machine name to load or NULL to load the default query - * type. + * type. */ public function getQueryType(); diff --git a/src/Widget/WidgetPluginBase.php b/src/Widget/WidgetPluginBase.php index b653d49..4331eef 100644 --- a/src/Widget/WidgetPluginBase.php +++ b/src/Widget/WidgetPluginBase.php @@ -83,7 +83,7 @@ public function build(FacetInterface $facet) { * This allows the following template suggestions: * - facets-item-list--WIDGET_TYPE--FACET_ID * - facets-item-list--WIDGET_TYPE - * - facets-item-list + * - facets-item-list. * * @param \Drupal\facets\FacetInterface $facet * The facet whose output is being generated. diff --git a/src/Widget/WidgetPluginInterface.php b/src/Widget/WidgetPluginInterface.php index 2a819c7..34651c3 100644 --- a/src/Widget/WidgetPluginInterface.php +++ b/src/Widget/WidgetPluginInterface.php @@ -25,9 +25,9 @@ public function build(FacetInterface $facet); /** * Picks the preferred query type for this widget. * - * @return string|NULL + * @return string|null * The query type machine name to load or NULL to load the default query - * type. + * type. */ public function getQueryType(); diff --git a/tests/facets_custom_widget/src/Plugin/facets/processor/InvalidQT.php b/tests/facets_custom_widget/src/Plugin/facets/processor/InvalidQT.php index 66f7636..f659823 100644 --- a/tests/facets_custom_widget/src/Plugin/facets/processor/InvalidQT.php +++ b/tests/facets_custom_widget/src/Plugin/facets/processor/InvalidQT.php @@ -2,9 +2,6 @@ namespace Drupal\facets_custom_widget\Plugin\facets\processor; -use Drupal\Core\Form\FormStateInterface; -use Drupal\facets\FacetInterface; -use Drupal\facets\Processor\PreQueryProcessorInterface; use Drupal\facets\Processor\ProcessorPluginBase; /** diff --git a/tests/src/Kernel/Entity/FacetFacetSourceTest.php b/tests/src/Kernel/Entity/FacetFacetSourceTest.php index 72b9b31..27e26bf 100644 --- a/tests/src/Kernel/Entity/FacetFacetSourceTest.php +++ b/tests/src/Kernel/Entity/FacetFacetSourceTest.php @@ -175,7 +175,12 @@ public function testQueryTypeJugglingInvalidCombo() { $entity->setWidget('numericgranular'); $entity->setFacetSourceId('search_api:views_page__search_api_test_view__page_1'); $entity->setFieldIdentifier('name'); - $entity->addProcessor(['processor_id' => 'test_pre_query', 'weights' => [], 'settings' => []]); + $processor = [ + 'processor_id' => 'test_pre_query', + 'weights' => [], + 'settings' => [], + ]; + $entity->addProcessor($processor); $this->setExpectedException(InvalidQueryTypeException::class); $entity->getQueryType(); diff --git a/tests/src/Kernel/Plugin/query_type/SearchApiDateTest.php b/tests/src/Kernel/Plugin/query_type/SearchApiDateTest.php index 5f8a8bb..d78980c 100644 --- a/tests/src/Kernel/Plugin/query_type/SearchApiDateTest.php +++ b/tests/src/Kernel/Plugin/query_type/SearchApiDateTest.php @@ -33,31 +33,21 @@ public function setUp() { */ public function testQueryTypeAnd($granularity, $original_results, $grouped_results) { $query = new SearchApiQuery([], 'search_api_query', []); - $facetReflection = new \ReflectionClass('Drupal\facets\Entity\Facet'); $facet = new Facet( ['query_operator' => 'AND', 'widget' => 'links'], 'facets_facet' ); - $widget = $this->getMockBuilder('Drupal\facets\Widget\WidgetPluginInterface') - ->disableOriginalConstructor() - ->getMock(); - $widget->method('getConfiguration') - ->will($this->returnValue([ - 'granularity' => $granularity, - 'date_display' => '', - 'display_relative' => FALSE, - ])); - $widget_instance = $facetReflection->getProperty('widgetInstance'); - $widget_instance->setAccessible(TRUE); - $widget_instance->setValue($facet, $widget); $query_type = new SearchApiDate( [ 'facet' => $facet, 'query' => $query, 'results' => $original_results, + 'granularity' => $granularity, + 'date_display' => '', + 'display_relative' => FALSE, ], - 'search_api_string', + 'search_api_date', [] ); diff --git a/tests/src/Unit/Plugin/widget/WidgetTestBase.php b/tests/src/Unit/Plugin/widget/WidgetTestBase.php index 15bdc3f..8bee2f7 100644 --- a/tests/src/Unit/Plugin/widget/WidgetTestBase.php +++ b/tests/src/Unit/Plugin/widget/WidgetTestBase.php @@ -87,7 +87,7 @@ public function testDefaultConfiguration() { */ public function testGetQueryType() { $result = $this->widget->getQueryType($this->queryTypes); - $this->assertEquals('string', $result); + $this->assertEquals(NULL, $result); } /**