public function EntityResourceTest::testGetFilteredCollection in JSON:API 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/Controller/EntityResourceTest.php \Drupal\Tests\jsonapi\Kernel\Controller\EntityResourceTest::testGetFilteredCollection()
@covers ::getCollection
File
- tests/
src/ Kernel/ Controller/ EntityResourceTest.php, line 253
Class
- EntityResourceTest
- @coversDefaultClass \Drupal\jsonapi\Controller\EntityResource @group jsonapi @group legacy
Namespace
Drupal\Tests\jsonapi\Kernel\ControllerCode
public function testGetFilteredCollection() {
$request = Request::create('/jsonapi/node/article');
$request->query = new ParameterBag([
'filter' => [
'type' => 'article',
],
]);
$entity_resource = $this
->createEntityResource();
// Get the response.
$resource_type = $this->container
->get('jsonapi.resource_type.repository')
->get('node_type', 'node_type');
$response = $entity_resource
->getCollection($resource_type, $request);
// Assertions.
$this
->assertInstanceOf(JsonApiDocumentTopLevel::class, $response
->getResponseData());
$this
->assertInstanceOf(Data::class, $response
->getResponseData()
->getData());
$this
->assertCount(1, $response
->getResponseData()
->getData());
$expected_cache_tags = [
'config:node.type.article',
'config:node_type_list',
];
$this
->assertSame($expected_cache_tags, $response
->getCacheableMetadata()
->getCacheTags());
}