trait JsonApiJsonSchemaTestTrait
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 14
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;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Member alias | Overriden Title | Overrides |
---|---|---|---|---|---|---|
JsonApiJsonSchemaTestTrait::getJsonSchemaTestNormalizationFormat | protected | function | Format that should be used when performing test normalizations. | Overrides JsonSchemaTestTrait::getJsonSchemaTestNormalizationFormat | ||
JsonApiJsonSchemaTestTrait::getNormalizationForValue | protected | function | ||||
JsonApiJsonSchemaTestTrait::getValidator | protected | function | Get the JSON Schema Validator. | Overrides JsonSchemaTestTrait::getValidator | ||
JsonSchemaTestTrait::doCheckSchemaAgainstMetaSchema | protected | function | Check a schema is valid against the meta-schema. | |||
JsonSchemaTestTrait::doProphesize | public | function | Method to make prophecy public for use in data provider closures. | |||
JsonSchemaTestTrait::doTestJsonSchemaIsValid | public | function | Validate the normalizer's JSON schema. | |||
JsonSchemaTestTrait::getNormalizationForValue | protected | function | Get the normalization for a value. | Aliased as: parentGetNormalizationForValue | ||
JsonSchemaTestTrait::getNormalizer | protected | function | Helper method to retrieve the normalizer. | 1 | ||
JsonSchemaTestTrait::jsonSchemaDataProvider | abstract public static | function | Data provider for ::testNormalizedValuesAgainstJsonSchema. | 7 | ||
JsonSchemaTestTrait::supportedTypesDataProvider | public static | function | ||||
JsonSchemaTestTrait::testNormalizedValuesAgainstJsonSchema | public | function | Test normalized values against the JSON schema. | |||
JsonSchemaTestTrait::testSupportedTypesSchemaIsValid | public | function | Test that a valid schema is returned for the explicitly supported types. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.