function DateElementBaseTest::providerTestDatetimeRangeYears
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Datetime/Element/DateElementBaseTest.php \Drupal\Tests\Core\Datetime\Element\DateElementBaseTest::providerTestDatetimeRangeYears()
Data provider for testDatetimeRangeYears().
File
-
core/
tests/ Drupal/ Tests/ Core/ Datetime/ Element/ DateElementBaseTest.php, line 65
Class
- DateElementBaseTest
- Tests the DateElementBase class.
Namespace
Drupal\Tests\Core\Datetime\ElementCode
public static function providerTestDatetimeRangeYears() : array {
$this_year = (int) date('Y');
return [
'standard 4-digit range' => [
'1900:2050',
1900,
2050,
],
'year less than 1000' => [
'500:1500',
500,
1500,
],
'year zero as min' => [
'0:2050',
0,
2050,
],
'both years less than 1000' => [
'0:999',
0,
999,
],
'single digit year' => [
'1:9999',
1,
9999,
],
'relative max' => [
'1900:+0',
1900,
$this_year,
],
'year zero with relative max' => [
'0:+50',
0,
$this_year + 50,
],
'both relative' => [
'-5:+5',
$this_year - 5,
$this_year + 5,
],
'both year zero' => [
'0:0',
0,
0,
],
'both this year (+0)' => [
'+0:+0',
$this_year,
$this_year,
],
'both this year (-0)' => [
'-0:-0',
$this_year,
$this_year,
],
'negative four digit year' => [
'-1000:-0',
$this_year - 1000,
$this_year,
],
'negative three digit year' => [
'-100:-1',
$this_year - 100,
$this_year - 1,
],
'negative two digit year' => [
'-10:-1',
$this_year - 10,
$this_year - 1,
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.