function TimeZoneAbbreviationRouteTest::providerAbbreviationConversion

Same name in other branches
  1. 10 core/modules/system/tests/src/Functional/Datetime/TimeZoneAbbreviationRouteTest.php \Drupal\Tests\system\Functional\Datetime\TimeZoneAbbreviationRouteTest::providerAbbreviationConversion()
  2. 11.x core/modules/system/tests/src/Functional/Datetime/TimeZoneAbbreviationRouteTest.php \Drupal\Tests\system\Functional\Datetime\TimeZoneAbbreviationRouteTest::providerAbbreviationConversion()

Provides test data for testGet().

Return value

array Test scenarios.

File

core/modules/system/tests/src/Functional/Datetime/TimeZoneAbbreviationRouteTest.php, line 66

Class

TimeZoneAbbreviationRouteTest
Tests converting JavaScript time zone abbreviations to time zone identifiers.

Namespace

Drupal\Tests\system\Functional\Datetime

Code

public function providerAbbreviationConversion() {
    return [
        'valid, default offset' => [
            'CST/0/0',
            '"America\\/Chicago"',
        ],
        // This should be the same TZID as default value.
'valid, default, explicit' => [
            'CST/-1/0',
            '"America\\/Chicago"',
        ],
        // Same abbreviation but different offset.
'valid, default, alternative offset' => [
            'CST/28800/0',
            '"Asia\\/Chongqing"',
        ],
        // Using '0' as offset will get the best matching time zone for an offset.
'valid, no abbreviation, offset, no DST' => [
            '0/3600/0',
            '"Europe\\/Paris"',
        ],
        'valid, no abbreviation, offset, with DST' => [
            '0/3600/1',
            '"Europe\\/London"',
        ],
        'invalid, unknown abbreviation' => [
            'foo/0/0',
            NULL,
            FALSE,
        ],
        'invalid abbreviation, out of range (short)' => [
            'A',
            NULL,
            TRUE,
        ],
        'invalid abbreviation, out of range (long)' => [
            'ABCDEFGHIJK',
            NULL,
            TRUE,
        ],
        'invalid offset, non integer' => [
            'CST/foo',
            NULL,
            TRUE,
        ],
        'invalid offset, out of range (lower)' => [
            'CST/-100000',
            'false',
        ],
        'invalid offset, out of range (higher)' => [
            'CST/100000',
            'false',
        ],
        'invalid DST value' => [
            'CST/3600/blah',
            NULL,
            TRUE,
        ],
        'invalid DST value, out of range (lower)' => [
            'CST/3600/-2',
            NULL,
            TRUE,
        ],
        'invalid DST value, out of range (higher)' => [
            'CST/3600/2',
            NULL,
            TRUE,
        ],
    ];
}

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