function DateTimeNormalizerTest::jsonSchemaDataProvider

Generate test data for date data providers.

Return value

array Test data for time formats supported by DateTimeNormalizer.

Overrides JsonSchemaTestTrait::jsonSchemaDataProvider

File

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

Class

DateTimeNormalizerTest
Unit test coverage for @DataTypes implementing DateTimeInterface.

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public static function jsonSchemaDataProvider() : array {
    $case = function (UnitTestCase $test) {
        $drupal_date_time = $test->prophesize(DateTimeNormalizerTestDrupalDateTime::class);
        $drupal_date_time->setTimezone(new \DateTimeZone('Australia/Sydney'))
            ->willReturn($drupal_date_time->reveal());
        $drupal_date_time->format(\DateTime::RFC3339)
            ->willReturn('1983-07-12T05:00:00-05:00');
        $data = $test->prophesize(DateTimeInterface::class);
        $data->getDateTime()
            ->willReturn($drupal_date_time->reveal());
        return $data->reveal();
    };
    return [
        'RFC 3339' => [
            fn(UnitTestCase $test) => $case($test),
        ],
    ];
}

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