You are here

public function DateTimeItemTest::datetimeValidationProvider in Drupal 8

Same name and namespace in other branches
  1. 9 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()

Provider for testDatetimeValidation().

File

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

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',
      ],
    ],
  ];
}