You are here

public function DateTimeNormalizerTest::testDenormalizeException in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\DateTimeNormalizerTest::testDenormalizeException()
  2. 10 core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\DateTimeNormalizerTest::testDenormalizeException()

Tests the denormalize function with bad data.

@covers ::denormalize

File

core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php, line 168

Class

DateTimeNormalizerTest
Unit test coverage for @DataTypes implementing DateTimeInterface.

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public function testDenormalizeException() {
  $this
    ->expectException(UnexpectedValueException::class);
  $this
    ->expectExceptionMessage('The specified date "2016/11/06 09:02am GMT" is not in an accepted format: "Y-m-d\\TH:i:sP" (RFC 3339), "Y-m-d\\TH:i:sO" (ISO 8601).');
  $normalized = '2016/11/06 09:02am GMT';
  $this->normalizer
    ->denormalize($normalized, DateTimeInterface::class, NULL, []);
}