public function EntityResourceTest::testGetFilteredCollection in JSON:API 8
Same name and namespace in other branches
- 8.2 tests/src/Kernel/Controller/EntityResourceTest.php \Drupal\Tests\jsonapi\Kernel\Controller\EntityResourceTest::testGetFilteredCollection()
@covers ::getCollection
File
- tests/
src/ Kernel/ Controller/ EntityResourceTest.php, line 212
Class
- EntityResourceTest
- @coversDefaultClass \Drupal\jsonapi\Controller\EntityResource @group jsonapi @group legacy
Namespace
Drupal\Tests\jsonapi\Kernel\ControllerCode
public function testGetFilteredCollection() {
$filter = new Filter(new EntityConditionGroup('AND', [
new EntityCondition('type', 'article'),
]));
$request = new Request([], [], [
'_route_params' => [
'_json_api_params' => [
'filter' => $filter,
],
],
'_json_api_params' => [
'filter' => $filter,
],
]);
$entity_resource = new EntityResource($this->container
->get('jsonapi.resource_type.repository')
->get('node_type', 'node_type'), $this->container
->get('entity_type.manager'), $this->container
->get('entity_field.manager'), $this->container
->get('plugin.manager.field.field_type'), $this->container
->get('jsonapi.link_manager'), $this->container
->get('jsonapi.resource_type.repository'), $this->container
->get('renderer'));
// Get the response.
$response = $entity_resource
->getCollection($request);
// Assertions.
$this
->assertInstanceOf(JsonApiDocumentTopLevel::class, $response
->getResponseData());
$this
->assertInstanceOf(EntityCollection::class, $response
->getResponseData()
->getData());
$this
->assertCount(1, $response
->getResponseData()
->getData());
$this
->assertEquals([
'config:node_type_list',
], $response
->getCacheableMetadata()
->getCacheTags());
}