function DateTimeNormalizerTest::providerTestDenormalizeValidFormats

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

Data provider for testDenormalizeValidFormats.

Return value

array

File

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

Class

DateTimeNormalizerTest
Unit test coverage for @DataTypes implementing DateTimeInterface.

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public function providerTestDenormalizeValidFormats() {
    $data = [];
    $data['RFC3339'] = [
        '2016-11-06T09:02:00+00:00',
        new \DateTimeImmutable('2016-11-06T09:02:00+00:00'),
    ];
    $data['RFC3339 +0100'] = [
        '2016-11-06T09:02:00+01:00',
        new \DateTimeImmutable('2016-11-06T09:02:00+01:00'),
    ];
    $data['RFC3339 -0600'] = [
        '2016-11-06T09:02:00-06:00',
        new \DateTimeImmutable('2016-11-06T09:02:00-06:00'),
    ];
    $data['ISO8601'] = [
        '2016-11-06T09:02:00+0000',
        new \DateTimeImmutable('2016-11-06T09:02:00+00:00'),
    ];
    $data['ISO8601 +0100'] = [
        '2016-11-06T09:02:00+0100',
        new \DateTimeImmutable('2016-11-06T09:02:00+01:00'),
    ];
    $data['ISO8601 -0600'] = [
        '2016-11-06T09:02:00-0600',
        new \DateTimeImmutable('2016-11-06T09:02:00-06:00'),
    ];
    return $data;
}

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