function JsonApiDocumentTopLevelNormalizerTest::testNormalizeConfig
Same name in other branches
- 9 core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest::testNormalizeConfig()
- 8.9.x core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest::testNormalizeConfig()
- 11.x core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest::testNormalizeConfig()
@covers ::normalize
File
-
core/
modules/ jsonapi/ tests/ src/ Kernel/ Normalizer/ JsonApiDocumentTopLevelNormalizerTest.php, line 494
Class
- JsonApiDocumentTopLevelNormalizerTest
- @coversDefaultClass \Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer @group jsonapi @group #slow
Namespace
Drupal\Tests\jsonapi\Kernel\NormalizerCode
public function testNormalizeConfig() : void {
$resource_type = $this->container
->get('jsonapi.resource_type.repository')
->get('node_type', 'node_type');
$resource_object = ResourceObject::createFromEntity($resource_type, $this->nodeType);
$document_wrapper = new JsonApiDocumentTopLevel(new ResourceObjectData([
$resource_object,
], 1), new NullIncludedData(), new LinkCollection([]));
$jsonapi_doc_object = $this->getNormalizer()
->normalize($document_wrapper, 'api_json', [
'resource_type' => $resource_type,
'account' => NULL,
'sparse_fieldset' => [
'node_type--node_type' => [
'description',
'display_submitted',
],
],
]);
$normalized = $jsonapi_doc_object->getNormalization();
$this->assertSame([
'description',
'display_submitted',
], array_keys($normalized['data']['attributes']));
$this->assertSame($normalized['data']['id'], NodeType::load('article')->uuid());
$this->assertSame($normalized['data']['type'], 'node_type--node_type');
// Make sure that the cache tags for the includes and the requested entities
// are bubbling as expected.
$this->assertSame([
'config:node.type.article',
], $jsonapi_doc_object->getCacheTags());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.