function DateTimeItemTest::dateonlyValidationProvider

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

Provider for testDatetimeValidation().

File

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

Class

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

Namespace

Drupal\Tests\datetime\Kernel

Code

public function dateonlyValidationProvider() {
    return [
        // Valid date strings, but unsupported by DateTimeItem.
[
            'Thu, 03 Nov 2014',
        ],
        [
            'Thursday, November 3, 2016',
        ],
        [
            'Thu, 11/03/2016',
        ],
        [
            '11/03/2016',
        ],
        // Invalid date strings.
[
            'YYYY-01-01',
        ],
        [
            '2014-MM-01',
        ],
        [
            '2014-01-DD',
        ],
        // Invalid dates.
[
            '2014-13-01',
        ],
        [
            '2014-01-55',
        ],
        // Proper format for different field setting.
[
            '2014-01-01T20:00:00',
        ],
        // Wrong input type.
[
            [
                '2014',
                '01',
                '01',
            ],
        ],
    ];
}

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