function DateTimeIso8601NormalizerTest::jsonSchemaDataProvider
Overrides JsonSchemaTestTrait::jsonSchemaDataProvider
File
-
core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ DateTimeIso8601NormalizerTest.php, line 264
Class
- DateTimeIso8601NormalizerTest
- Unit test coverage for the "datetime_iso8601" @DataType.
Namespace
Drupal\Tests\serialization\Unit\NormalizerCode
public static function jsonSchemaDataProvider() : array {
$case = function (UnitTestCase $test) {
assert(in_array(JsonSchemaTestTrait::class, class_uses($test)));
$field_item = $test->doProphesize(DateTimeItem::class);
$data = $test->doProphesize(DateTimeIso8601::class);
$field_storage_definition = $test->doProphesize(FieldStorageDefinitionInterface::class);
$field_storage_definition->getSetting('datetime_type')
->willReturn(DateTimeItem::DATETIME_TYPE_DATE);
$field_definition = $test->doProphesize(FieldDefinitionInterface::class);
$field_definition->getFieldStorageDefinition()
->willReturn($field_storage_definition);
$field_item->getFieldDefinition()
->willReturn($field_definition);
$data->getParent()
->willReturn($field_item);
$drupal_date_time = $test->doProphesize(DateTimeIso8601NormalizerTestDrupalDateTime::class);
$drupal_date_time->setTimezone(new \DateTimeZone('Australia/Sydney'))
->willReturn($drupal_date_time->reveal());
$drupal_date_time->format('Y-m-d')
->willReturn('1991-09-19');
$data->getDateTime()
->willReturn($drupal_date_time->reveal());
return $data->reveal();
};
return [
'ISO 8601 date-only' => [
fn(UnitTestCase $test) => $case($test),
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.