trait JsonApiJsonSchemaTestTrait
Same name and namespace in other branches
- 11.x core/modules/jsonapi/tests/src/Traits/JsonApiJsonSchemaTestTrait.php \Drupal\Tests\jsonapi\Traits\JsonApiJsonSchemaTestTrait
Support methods for testing JSON API schema.
Hierarchy
- trait \Drupal\Tests\jsonapi\Traits\JsonApiJsonSchemaTestTrait uses \Drupal\Tests\serialization\Traits\JsonSchemaTestTrait
1 file declares its use of JsonApiJsonSchemaTestTrait
- JsonApiTopLevelResourceNormalizerTest.php in core/
modules/ jsonapi/ tests/ src/ Kernel/ Normalizer/ JsonApiTopLevelResourceNormalizerTest.php
File
-
core/
modules/ jsonapi/ tests/ src/ Traits/ JsonApiJsonSchemaTestTrait.php, line 17
Namespace
Drupal\Tests\jsonapi\TraitsView source
trait JsonApiJsonSchemaTestTrait {
use JsonSchemaTestTrait {
getNormalizationForValue as parentGetNormalizationForValue;
}
/**
* {@inheritdoc}
*/
protected function getJsonSchemaTestNormalizationFormat() : ?string {
return 'api_json';
}
/**
* {@inheritdoc}
*/
protected function getValidator() : Validator {
$uriRetriever = new UriRetriever();
$uriRetriever->setTranslation('|^' . JsonApiSpec::SUPPORTED_SPECIFICATION_JSON_SCHEMA . '#?|', sprintf('file://%s/schema.json', realpath(__DIR__ . '/../../..')));
return new Validator(new Factory(uriRetriever: $uriRetriever));
}
/**
* {@inheritdoc}
*/
protected function getNormalizationForValue(mixed $value) : mixed {
$normalization = $this->parentGetNormalizationForValue($value);
if ($normalization instanceof CacheableNormalization) {
return $normalization->getNormalization();
}
return $normalization;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.