function PrimitiveDataNormalizerTest::jsonSchemaDataProvider
Overrides JsonSchemaTestTrait::jsonSchemaDataProvider
File
-
core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ PrimitiveDataNormalizerTest.php, line 116
Class
- PrimitiveDataNormalizerTest
- @coversDefaultClass \Drupal\serialization\Normalizer\PrimitiveDataNormalizer @group serialization
Namespace
Drupal\Tests\serialization\Unit\NormalizerCode
public static function jsonSchemaDataProvider() : array {
$email = new Email(DataDefinition::createFromDataType('email'));
$email->setValue('test@example.com');
$float = new FloatData(DataDefinition::createFromDataType('float'));
$float->setValue(9.99);
$uri = new Uri(DataDefinition::createFromDataType('uri'));
$uri->setValue('https://example.com');
$decimal = new DecimalData(DataDefinition::createFromDataType('decimal'));
$decimal->setValue('9.99');
// TimeSpan normalizes to an integer, however Iso8601 matches a format.
$duration = new DurationIso8601(DataDefinition::createFromDataType('duration_iso8601'));
$duration->setValue('P1D');
return [
'email' => [
$email,
],
'float' => [
$float,
],
'uri' => [
$uri,
],
'decimal' => [
$decimal,
],
'duration' => [
$duration,
],
array_map(fn($value) => [
$value[0],
], static::dataProviderPrimitiveData()),
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.