function DateTimeItemTest::datetimeValidationProvider

Same name in other branches
  1. 8.9.x core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php \Drupal\Tests\datetime\Kernel\DateTimeItemTest::datetimeValidationProvider()
  2. 10 core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php \Drupal\Tests\datetime\Kernel\DateTimeItemTest::datetimeValidationProvider()
  3. 11.x core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php \Drupal\Tests\datetime\Kernel\DateTimeItemTest::datetimeValidationProvider()

Provider for testDatetimeValidation().

File

core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php, line 275

Class

DateTimeItemTest
Tests the new entity API for the date field type.

Namespace

Drupal\Tests\datetime\Kernel

Code

public function datetimeValidationProvider() {
    return [
        // Valid ISO 8601 dates, but unsupported by DateTimeItem.
[
            '2014-01-01T20:00:00Z',
        ],
        [
            '2014-01-01T20:00:00+04:00',
        ],
        [
            '2014-01-01T20:00:00+0400',
        ],
        [
            '2014-01-01T20:00:00+04',
        ],
        [
            '2014-01-01T20:00:00.123',
        ],
        [
            '2014-01-01T200000',
        ],
        [
            '2014-01-01T2000',
        ],
        [
            '2014-01-01T20',
        ],
        [
            '20140101T20:00:00',
        ],
        [
            '2014-01T20:00:00',
        ],
        [
            '2014-001T20:00:00',
        ],
        [
            '2014001T20:00:00',
        ],
        // Valid date strings, but unsupported by DateTimeItem.
[
            '2016-11-03 20:52:00',
        ],
        [
            'Thu, 03 Nov 2014 20:52:00 -0400',
        ],
        [
            'Thursday, November 3, 2016 - 20:52',
        ],
        [
            'Thu, 11/03/2016 - 20:52',
        ],
        [
            '11/03/2016 - 20:52',
        ],
        // Invalid date strings.
[
            'YYYY-01-01T20:00:00',
        ],
        [
            '2014-MM-01T20:00:00',
        ],
        [
            '2014-01-DDT20:00:00',
        ],
        [
            '2014-01-01Thh:00:00',
        ],
        [
            '2014-01-01T20:mm:00',
        ],
        [
            '2014-01-01T20:00:ss',
        ],
        // Invalid dates.
[
            '2014-13-13T20:00:00',
        ],
        [
            '2014-01-55T20:00:00',
        ],
        [
            '2014-01-01T25:00:00',
        ],
        [
            '2014-01-01T00:70:00',
        ],
        [
            '2014-01-01T00:00:70',
        ],
        // Proper format for different field setting.
[
            '2014-01-01',
        ],
        // Wrong input type.
[
            [
                '2014',
                '01',
                '01',
                '00',
                '00',
                '00',
            ],
        ],
    ];
}

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