public function SearchApiDateTest::testQueryTypeAnd in Facets 8
Tests string query type without executing the query with an "AND" operator.
@dataProvider resultsProvider
File
- tests/
src/ Kernel/ Plugin/ query_type/ SearchApiDateTest.php, line 51
Class
- SearchApiDateTest
- Kernel test for date query type.
Namespace
Drupal\Tests\facets\Kernel\Plugin\query_typeCode
public function testQueryTypeAnd($granularity, $original_results, $grouped_results) {
$backend = $this
->prophesize(BackendInterface::class);
$backend
->getSupportedFeatures()
->willReturn([]);
$server = $this
->prophesize(ServerInterface::class);
$server
->getBackend()
->willReturn($backend);
$index = $this
->prophesize(IndexInterface::class);
$index
->getServerInstance()
->willReturn($server);
$query = $this
->prophesize(SearchApiQuery::class);
$query
->getIndex()
->willReturn($index);
$facet = new Facet([
'query_operator' => 'AND',
'widget' => 'links',
], 'facets_facet');
$facet
->addProcessor([
'processor_id' => 'date_item',
'weights' => [],
'settings' => [
'granularity' => $granularity,
'date_format' => '',
'date_display' => 'actual_date',
],
]);
$query_type = new SearchApiDate([
'facet' => $facet,
'query' => $query
->reveal(),
'results' => $original_results,
], 'search_api_date', []);
$built_facet = $query_type
->build();
$this
->assertInstanceOf(FacetInterface::class, $built_facet);
$results = $built_facet
->getResults();
$this
->assertSame('array', gettype($results));
foreach ($grouped_results as $k => $result) {
$this
->assertInstanceOf(ResultInterface::class, $results[$k]);
$this
->assertEquals($result['count'], $results[$k]
->getCount());
$this
->assertEquals($result['filter'], $results[$k]
->getDisplayValue());
}
}