function DateTimeIso8601NormalizerTest::testNormalizeWhenNull
Same name in other branches
- 9 core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\DateTimeIso8601NormalizerTest::testNormalizeWhenNull()
- 10 core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\DateTimeIso8601NormalizerTest::testNormalizeWhenNull()
- 11.x core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\DateTimeIso8601NormalizerTest::testNormalizeWhenNull()
@covers ::normalize @dataProvider providerTestNormalize
File
-
core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ DateTimeIso8601NormalizerTest.php, line 123
Class
- DateTimeIso8601NormalizerTest
- Unit test coverage for the "datetime_iso8601" @DataType.
Namespace
Drupal\Tests\serialization\Unit\NormalizerCode
public function testNormalizeWhenNull($parent_field_item_class, $datetime_type, $expected_format) {
$field_item = $this->prophesize($parent_field_item_class);
if ($parent_field_item_class === DateTimeItem::class) {
$field_storage_definition = $this->prophesize(FieldStorageDefinitionInterface::class);
$field_storage_definition->getSetting('datetime_type')
->willReturn($datetime_type);
$field_definition = $this->prophesize(FieldDefinitionInterface::class);
$field_definition->getFieldStorageDefinition()
->willReturn($field_storage_definition);
$field_item->getFieldDefinition()
->willReturn($field_definition);
}
else {
$field_item->getFieldDefinition(Argument::any())
->shouldNotBeCalled();
}
$this->data
->getParent()
->willReturn($field_item);
$this->data
->getDateTime()
->willReturn(NULL);
$normalized = $this->normalizer
->normalize($this->data
->reveal());
$this->assertNull($normalized);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.