function TimestampNormalizerTest::testDenormalizeException

Same name in other branches
  1. 8.9.x core/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\TimestampNormalizerTest::testDenormalizeException()
  2. 10 core/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\TimestampNormalizerTest::testDenormalizeException()
  3. 11.x core/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\TimestampNormalizerTest::testDenormalizeException()

Tests the denormalize function with bad data.

@covers ::denormalize

File

core/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php, line 124

Class

TimestampNormalizerTest
Unit test coverage for the "Timestamp" @DataType.

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: "U" (UNIX timestamp), "Y-m-d\\TH:i:sO" (ISO 8601), "Y-m-d\\TH:i:sP" (RFC 3339).');
    $normalized = '2016/11/06 09:02am GMT';
    $this->normalizer
        ->denormalize($normalized, Timestamp::class, NULL, []);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.