function DateTimePlusTest::providerTestInvalidDateArrays

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::providerTestInvalidDateArrays()
  2. 10 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::providerTestInvalidDateArrays()
  3. 11.x core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::providerTestInvalidDateArrays()

Data provider for testInvalidDateArrays.

Return value

array An array of arrays, each containing:

  • 'input' - Input for DateTimePlus.
  • 'timezone' - Timezone for DateTimePlus.

See also

testInvalidDateArrays

File

core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php, line 445

Class

DateTimePlusTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Datetime%21DateTimePlus.php/class/DateTimePlus/8.9.x" title="Wraps DateTime()." class="local">\Drupal\Component\Datetime\DateTimePlus</a> @group Datetime

Namespace

Drupal\Tests\Component\Datetime

Code

public function providerTestInvalidDateArrays() {
    return [
        // One year larger than the documented upper limit of checkdate().
[
            [
                'year' => 32768,
                'month' => 1,
                'day' => 8,
                'hour' => 8,
                'minute' => 0,
                'second' => 0,
            ],
            'America/Chicago',
            \InvalidArgumentException::class,
        ],
        // One year smaller than the documented lower limit of checkdate().
[
            [
                'year' => 0,
                'month' => 1,
                'day' => 8,
                'hour' => 8,
                'minute' => 0,
                'second' => 0,
            ],
            'America/Chicago',
            \InvalidArgumentException::class,
        ],
        // Test for invalid month from date array.
[
            [
                'year' => 2010,
                'month' => 27,
                'day' => 8,
                'hour' => 8,
                'minute' => 0,
                'second' => 0,
            ],
            'America/Chicago',
            \InvalidArgumentException::class,
        ],
        // Test for invalid hour from date array.
[
            [
                'year' => 2010,
                'month' => 2,
                'day' => 28,
                'hour' => 80,
                'minute' => 0,
                'second' => 0,
            ],
            'America/Chicago',
            \InvalidArgumentException::class,
        ],
        // Test for invalid minute from date array.
[
            [
                'year' => 2010,
                'month' => 7,
                'day' => 8,
                'hour' => 8,
                'minute' => 88,
                'second' => 0,
            ],
            'America/Chicago',
            \InvalidArgumentException::class,
        ],
        // Regression test for https://www.drupal.org/node/2084455.
[
            [
                'hour' => 59,
                'minute' => 1,
                'second' => 1,
            ],
            'America/Chicago',
            \InvalidArgumentException::class,
        ],
    ];
}

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