function JsonApiTopLevelResourceNormalizerTest::testConfigEntityResourceObjectSchema
Test the generated config resource object normalization against the schema.
@covers \Drupal\jsonapi\Normalizer\ResourceObjectNormalizer::normalize @covers \Drupal\jsonapi\Normalizer\ResourceObjectNormalizer::getNormalizationSchema
File
-
core/
modules/ jsonapi/ tests/ src/ Kernel/ Normalizer/ JsonApiTopLevelResourceNormalizerTest.php, line 895
Class
- JsonApiTopLevelResourceNormalizerTest
- @coversDefaultClass \Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer @group jsonapi
Namespace
Drupal\Tests\jsonapi\Kernel\NormalizerCode
public function testConfigEntityResourceObjectSchema() : void {
[
,
$resource_object,
] = $this->getTestConfigEntityResource();
$serializer = $this->container
->get('jsonapi.serializer');
$context = [
'account' => NULL,
];
$format = $this->getJsonSchemaTestNormalizationFormat();
$schema = $serializer->normalize($resource_object, 'json_schema', $context);
$this->doCheckSchemaAgainstMetaSchema($schema);
$normalized = json_decode(json_encode($serializer->normalize($resource_object, $format, $context)
->getNormalization()));
$validator = $this->getValidator();
$validator->validate($normalized, json_decode(json_encode($schema)));
$this->assertSame([], $validator->getErrors(), 'Validation errors on object ' . print_r($normalized, TRUE) . ' with schema ' . print_r($schema, TRUE));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.