function DateTimePlusTest::providerTestInvalidDates

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

Provides data for testInvalidDates.

Return value

array An array of arrays, each containing:

See also

testInvalidDates

File

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

Class

DateTimePlusTest
@coversDefaultClass \Drupal\Component\Datetime\DateTimePlus[[api-linebreak]] @group Datetime

Namespace

Drupal\Tests\Component\Datetime

Code

public static function providerTestInvalidDates() {
  return [
    // Test for invalid month names when we are using a short version
    // of the month.
[
      '23 abc 2012',
      NULL,
      'd M Y',
      "23 abc 2012 contains an invalid month name and did not produce errors.",
      \InvalidArgumentException::class,
    ],
    // Test for invalid hour.
[
      '0000-00-00T45:30:00',
      NULL,
      'Y-m-d\\TH:i:s',
      "0000-00-00T45:30:00 contains an invalid hour and did not produce errors.",
      \UnexpectedValueException::class,
    ],
    // Test for invalid day.
[
      '0000-00-99T05:30:00',
      NULL,
      'Y-m-d\\TH:i:s',
      "0000-00-99T05:30:00 contains an invalid day and did not produce errors.",
      \UnexpectedValueException::class,
    ],
    // Test for invalid month.
[
      '0000-75-00T15:30:00',
      NULL,
      'Y-m-d\\TH:i:s',
      "0000-75-00T15:30:00 contains an invalid month and did not produce errors.",
      \UnexpectedValueException::class,
    ],
    // Test for invalid year.
[
      '11-08-01T15:30:00',
      NULL,
      'Y-m-d\\TH:i:s',
      "11-08-01T15:30:00 contains an invalid year and did not produce errors.",
      \UnexpectedValueException::class,
    ],
  ];
}

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