function TimestampNormalizerTest::providerTestDenormalizeValidFormats

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

Data provider for testDenormalizeValidFormats.

Return value

array

File

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

Class

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

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public function providerTestDenormalizeValidFormats() {
    $expected_stamp = 1478422920;
    $data = [];
    $data['U'] = [
        $expected_stamp,
        $expected_stamp,
    ];
    $data['RFC3339'] = [
        '2016-11-06T09:02:00+00:00',
        $expected_stamp,
    ];
    $data['RFC3339 +0100'] = [
        '2016-11-06T09:02:00+01:00',
        $expected_stamp - 1 * 3600,
    ];
    $data['RFC3339 -0600'] = [
        '2016-11-06T09:02:00-06:00',
        $expected_stamp + 6 * 3600,
    ];
    $data['ISO8601'] = [
        '2016-11-06T09:02:00+0000',
        $expected_stamp,
    ];
    $data['ISO8601 +0100'] = [
        '2016-11-06T09:02:00+0100',
        $expected_stamp - 1 * 3600,
    ];
    $data['ISO8601 -0600'] = [
        '2016-11-06T09:02:00-0600',
        $expected_stamp + 6 * 3600,
    ];
    return $data;
}

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