public function FilterTest::testQueryCondition in JSON:API 8
Same name and namespace in other branches
- 8.2 tests/src/Kernel/Query/FilterTest.php \Drupal\Tests\jsonapi\Kernel\Query\FilterTest::testQueryCondition()
@covers ::queryCondition
File
- tests/
src/ Kernel/ Query/ FilterTest.php, line 74
Class
- FilterTest
- @coversDefaultClass \Drupal\jsonapi\Query\Filter @group jsonapi @group jsonapi_query @group legacy
Namespace
Drupal\Tests\jsonapi\Kernel\QueryCode
public function testQueryCondition() {
// Can't use a data provider because we need access to the container.
$data = $this
->queryConditionData();
foreach ($data as $case) {
$normalized = $case[0];
$expected_query = $case[1];
// Denormalize the test filter into the object we want to test.
$filter = $this->normalizer
->denormalize($normalized, Filter::class, NULL, [
'entity_type_id' => 'node',
'bundle' => 'painting',
]);
$query = $this->nodeStorage
->getQuery();
// Get the query condition parsed from the input.
$condition = $filter
->queryCondition($query);
// Apply it to the query.
$query
->condition($condition);
// Compare the results.
$this
->assertEquals($expected_query
->execute(), $query
->execute());
}
}