public function DateTest::providerTestFormatInterval in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Datetime/DateTest.php \Drupal\Tests\Core\Datetime\DateTest::providerTestFormatInterval()
Provides some test data for the format interval test.
File
- core/
tests/ Drupal/ Tests/ Core/ Datetime/ DateTest.php, line 116
Class
- DateTest
- @coversDefaultClass \Drupal\Core\Datetime\DateFormatter @group Datetime
Namespace
Drupal\Tests\Core\DatetimeCode
public function providerTestFormatInterval() {
$data = [
// Checks for basic seconds.
[
1,
1,
'1 sec',
],
[
1,
2,
'1 sec',
],
[
2,
1,
'2 sec',
],
[
2,
2,
'2 sec',
],
// Checks for minutes with seconds.
[
61,
1,
'1 min',
],
[
61,
2,
'1 min 1 sec',
],
[
62,
2,
'1 min 2 sec',
],
[
121,
1,
'2 min',
],
[
121,
2,
'2 min 1 sec',
],
// Check for hours with minutes and seconds.
[
3601,
1,
'1 hour',
],
[
3601,
2,
'1 hour',
],
// Check for higher units.
[
86401,
1,
'1 day',
],
[
604800,
1,
'1 week',
],
[
2592000 * 2,
1,
'2 months',
],
[
31536000 * 2,
1,
'2 years',
],
// Check for a complicated one with months weeks and days.
[
2592000 * 2 + 604800 * 3 + 86400 * 4,
3,
'2 months 3 weeks 4 days',
],
// Check for the langcode.
[
61,
1,
'1 min',
'xxx-lolspeak',
],
// Check with an unspecified granularity.
[
61,
NULL,
'1 min 1 sec',
],
];
return $data;
}