function DateTimeIso8601NormalizerTest::testDenormalizeDateAndTimeException
Same name in other branches
- 9 core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\DateTimeIso8601NormalizerTest::testDenormalizeDateAndTimeException()
- 10 core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\DateTimeIso8601NormalizerTest::testDenormalizeDateAndTimeException()
- 11.x core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\DateTimeIso8601NormalizerTest::testDenormalizeDateAndTimeException()
Tests the denormalize function with bad data for the date+time case.
@covers ::denormalize
File
-
core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ DateTimeIso8601NormalizerTest.php, line 249
Class
- DateTimeIso8601NormalizerTest
- Unit test coverage for the "datetime_iso8601" @DataType.
Namespace
Drupal\Tests\serialization\Unit\NormalizerCode
public function testDenormalizeDateAndTimeException() {
$this->expectException(UnexpectedValueException::class);
$this->expectExceptionMessage('The specified date "on a rainy day" is not in an accepted format: "Y-m-d\\TH:i:sP" (RFC 3339), "Y-m-d\\TH:i:sO" (ISO 8601), "Y-m-d\\TH:i:s" (backward compatibility — deprecated).');
$normalized = 'on a rainy day';
$field_definition = $this->prophesize(FieldDefinitionInterface::class);
$field_definition->getSetting('datetime_type')
->willReturn(DateTimeItem::DATETIME_TYPE_DATETIME);
$this->normalizer
->denormalize($normalized, DateTimeIso8601::class, NULL, [
'field_definition' => $field_definition->reveal(),
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.