You are here

public function DateTimePlusTest::providerTestCheckArray in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::providerTestCheckArray()
  2. 9 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::providerTestCheckArray()

Data provider for testCheckArray.

Return value

array An array of arrays, each containing:

See also

testCheckArray

File

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

Class

DateTimePlusTest
@coversDefaultClass \Drupal\Component\Datetime\DateTimePlus @group Datetime

Namespace

Drupal\Tests\Component\Datetime

Code

public function providerTestCheckArray() {
  return [
    'Date array, date only' => [
      [
        'year' => 2010,
        'month' => 2,
        'day' => 28,
      ],
      TRUE,
    ],
    'Date array with hour' => [
      [
        'year' => 2010,
        'month' => 2,
        'day' => 28,
        'hour' => 10,
      ],
      TRUE,
    ],
    'One year larger than the documented upper limit of checkdate()' => [
      [
        'year' => 32768,
        'month' => 1,
        'day' => 8,
        'hour' => 8,
        'minute' => 0,
        'second' => 0,
      ],
      FALSE,
    ],
    'One year smaller than the documented lower limit of checkdate()' => [
      [
        'year' => 0,
        'month' => 1,
        'day' => 8,
        'hour' => 8,
        'minute' => 0,
        'second' => 0,
      ],
      FALSE,
    ],
    'Invalid month from date array' => [
      [
        'year' => 2010,
        'month' => 27,
        'day' => 8,
        'hour' => 8,
        'minute' => 0,
        'second' => 0,
      ],
      FALSE,
    ],
    'Invalid hour from date array' => [
      [
        'year' => 2010,
        'month' => 2,
        'day' => 28,
        'hour' => 80,
        'minute' => 0,
        'second' => 0,
      ],
      FALSE,
    ],
    'Invalid minute from date array.' => [
      [
        'year' => 2010,
        'month' => 7,
        'day' => 8,
        'hour' => 8,
        'minute' => 88,
        'second' => 0,
      ],
      FALSE,
    ],
    'Missing day' => [
      [
        'year' => 2059,
        'month' => 1,
        'second' => 1,
      ],
      FALSE,
    ],
    'Zero day' => [
      [
        'year' => 2059,
        'month' => 1,
        'day' => 0,
      ],
      FALSE,
    ],
  ];
}