public function DateRangeTest::testRangeQueries in Search API Solr 8.2
Same name and namespace in other branches
- 8.3 tests/src/Kernel/Processor/DateRangeTest.php \Drupal\Tests\search_api_solr\Kernel\Processor\DateRangeTest::testRangeQueries()
- 4.x tests/src/Kernel/Processor/DateRangeTest.php \Drupal\Tests\search_api_solr\Kernel\Processor\DateRangeTest::testRangeQueries()
Tests date range queries.
@dataProvider rangeQueryDataProvider
Throws
\Drupal\search_api\SearchApiException
File
- tests/
src/ Kernel/ Processor/ DateRangeTest.php, line 173
Class
- DateRangeTest
- Tests the "Date range" processor.
Namespace
Drupal\Tests\search_api_solr\Kernel\ProcessorCode
public function testRangeQueries(string $field, string $date1, string $date2) {
$this
->indexItems();
$query_helper = \Drupal::getContainer()
->get('search_api.query_helper');
$query = $query_helper
->createQuery($this->index);
$result = $query
->execute();
$expected = [
'node' => [
0,
1,
],
];
$this
->assertResults($result, $expected);
$query = $query_helper
->createQuery($this->index);
$query
->addCondition($field, $date1);
$result = $query
->execute();
$expected = [
'node' => [
1,
],
];
$this
->assertResults($result, $expected);
$query = $query_helper
->createQuery($this->index);
$query
->addCondition($field, $date2);
$result = $query
->execute();
$expected = [
'node' => [
0,
1,
],
];
$this
->assertResults($result, $expected);
}