public function DateTest::providerTestFormatDiff in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Datetime/DateTest.php \Drupal\Tests\Core\Datetime\DateTest::providerTestFormatDiff()
Data provider for testformatDiff().
File
- core/
tests/ Drupal/ Tests/ Core/ Datetime/ DateTest.php, line 271 - Contains \Drupal\Tests\Core\Datetime\DateTest.
Class
- DateTest
- @coversDefaultClass \Drupal\Core\Datetime\DateFormatter @group Datetime
Namespace
Drupal\Tests\Core\DatetimeCode
public function providerTestFormatDiff() {
// This is the fixed request time in the test.
$request_time = $this
->createTimestamp('2013-12-11 10:09:08');
$granularity_3 = array(
'granularity' => 3,
);
$granularity_4 = array(
'granularity' => 4,
);
$langcode_en = array(
'langcode' => 'en',
);
$langcode_lolspeak = array(
'langcode' => 'xxx-lolspeak',
);
$non_strict = array(
'strict' => FALSE,
);
$data = array(
// Checks for equal timestamps.
array(
'0 seconds',
$request_time,
$request_time,
),
// Checks for seconds only.
array(
'1 second',
$this
->createTimestamp('2013-12-11 10:09:07'),
$request_time,
),
array(
'1 second',
$this
->createTimestamp('2013-12-11 10:09:07'),
$request_time,
),
array(
'1 second',
$this
->createTimestamp('2013-12-11 10:09:07'),
$request_time,
$granularity_3 + $langcode_en,
),
array(
'1 second',
$this
->createTimestamp('2013-12-11 10:09:07'),
$request_time,
$granularity_4 + $langcode_lolspeak,
),
array(
'2 seconds',
$this
->createTimestamp('2013-12-11 10:09:06'),
$request_time,
),
array(
'59 seconds',
$this
->createTimestamp('2013-12-11 10:08:09'),
$request_time,
),
array(
'59 seconds',
$this
->createTimestamp('2013-12-11 10:08:09'),
$request_time,
),
// Checks for minutes and possibly seconds.
array(
'1 minute',
$this
->createTimestamp('2013-12-11 10:08:08'),
$request_time,
),
array(
'1 minute',
$this
->createTimestamp('2013-12-11 10:08:08'),
$request_time,
),
array(
'1 minute 1 second',
$this
->createTimestamp('2013-12-11 10:08:07'),
$request_time,
),
array(
'1 minute 59 seconds',
$this
->createTimestamp('2013-12-11 10:07:09'),
$request_time,
),
array(
'2 minutes',
$this
->createTimestamp('2013-12-11 10:07:08'),
$request_time,
),
array(
'2 minutes 1 second',
$this
->createTimestamp('2013-12-11 10:07:07'),
$request_time,
),
array(
'2 minutes 2 seconds',
$this
->createTimestamp('2013-12-11 10:07:06'),
$request_time,
),
array(
'2 minutes 2 seconds',
$this
->createTimestamp('2013-12-11 10:07:06'),
$request_time,
$granularity_3,
),
array(
'2 minutes 2 seconds',
$this
->createTimestamp('2013-12-11 10:07:06'),
$request_time,
$granularity_4,
),
array(
'30 minutes',
$this
->createTimestamp('2013-12-11 09:39:08'),
$request_time,
),
array(
'59 minutes 59 seconds',
$this
->createTimestamp('2013-12-11 09:09:09'),
$request_time,
),
array(
'59 minutes 59 seconds',
$this
->createTimestamp('2013-12-11 09:09:09'),
$request_time,
),
// Checks for hours and possibly minutes or seconds.
array(
'1 hour',
$this
->createTimestamp('2013-12-11 09:09:08'),
$request_time,
),
array(
'1 hour',
$this
->createTimestamp('2013-12-11 09:09:08'),
$request_time,
),
array(
'1 hour',
$this
->createTimestamp('2013-12-11 09:09:07'),
$request_time,
),
array(
'1 hour',
$this
->createTimestamp('2013-12-11 09:09:06'),
$request_time,
),
array(
'1 hour 1 minute',
$this
->createTimestamp('2013-12-11 09:08:08'),
$request_time,
),
array(
'1 hour 1 minute 1 second',
$this
->createTimestamp('2013-12-11 09:08:07'),
$request_time,
$granularity_3,
),
array(
'1 hour 1 minute 2 seconds',
$this
->createTimestamp('2013-12-11 09:08:06'),
$request_time,
$granularity_4,
),
array(
'1 hour 30 minutes',
$this
->createTimestamp('2013-12-11 08:39:08'),
$request_time,
),
array(
'2 hours',
$this
->createTimestamp('2013-12-11 08:09:08'),
$request_time,
),
array(
'23 hours 59 minutes',
$this
->createTimestamp('2013-12-10 10:10:08'),
$request_time,
),
// Checks for days and possibly hours, minutes or seconds.
array(
'1 day',
$this
->createTimestamp('2013-12-10 10:09:08'),
$request_time,
),
array(
'1 day',
$this
->createTimestamp('2013-12-10 10:09:07'),
$request_time,
),
array(
'1 day 1 hour',
$this
->createTimestamp('2013-12-10 09:09:08'),
$request_time,
),
array(
'1 day 1 hour 1 minute',
$this
->createTimestamp('2013-12-10 09:08:07'),
$request_time,
$granularity_3 + $langcode_en,
),
array(
'1 day 1 hour 1 minute 1 second',
$this
->createTimestamp('2013-12-10 09:08:07'),
$request_time,
$granularity_4 + $langcode_lolspeak,
),
array(
'1 day 2 hours 2 minutes 2 seconds',
$this
->createTimestamp('2013-12-10 08:07:06'),
$request_time,
$granularity_4,
),
array(
'2 days',
$this
->createTimestamp('2013-12-09 10:09:08'),
$request_time,
),
array(
'2 days',
$this
->createTimestamp('2013-12-09 10:07:08'),
$request_time,
),
array(
'2 days 2 hours',
$this
->createTimestamp('2013-12-09 08:09:08'),
$request_time,
),
array(
'2 days 2 hours 2 minutes',
$this
->createTimestamp('2013-12-09 08:07:06'),
$request_time,
$granularity_3 + $langcode_en,
),
array(
'2 days 2 hours 2 minutes 2 seconds',
$this
->createTimestamp('2013-12-09 08:07:06'),
$request_time,
$granularity_4 + $langcode_lolspeak,
),
// Checks for weeks and possibly days, hours, minutes or seconds.
array(
'1 week',
$this
->createTimestamp('2013-12-04 10:09:08'),
$request_time,
),
array(
'1 week 1 day',
$this
->createTimestamp('2013-12-03 10:09:08'),
$request_time,
),
array(
'2 weeks',
$this
->createTimestamp('2013-11-27 10:09:08'),
$request_time,
),
array(
'2 weeks 2 days',
$this
->createTimestamp('2013-11-25 08:07:08'),
$request_time,
),
array(
'2 weeks 2 days 2 hours 2 minutes',
$this
->createTimestamp('2013-11-25 08:07:08'),
$request_time,
$granularity_4,
),
array(
'4 weeks',
$this
->createTimestamp('2013-11-13 10:09:08'),
$request_time,
),
array(
'4 weeks 1 day',
$this
->createTimestamp('2013-11-12 10:09:08'),
$request_time,
),
// Checks for months and possibly days, hours, minutes or seconds.
array(
'1 month',
$this
->createTimestamp('2013-11-11 10:09:08'),
$request_time,
),
array(
'1 month',
$this
->createTimestamp('2013-11-11 10:09:07'),
$request_time,
),
array(
'1 month',
$this
->createTimestamp('2013-11-11 09:09:08'),
$request_time,
),
array(
'1 month',
$this
->createTimestamp('2013-11-11 09:08:07'),
$request_time,
$granularity_3,
),
array(
'1 month',
$this
->createTimestamp('2013-11-11 09:08:07'),
$request_time,
$granularity_4,
),
array(
'1 month 4 weeks',
$this
->createTimestamp('2013-10-13 10:09:08'),
$request_time,
),
array(
'1 month 4 weeks 1 day',
$this
->createTimestamp('2013-10-13 10:09:08'),
$request_time,
$granularity_3,
),
array(
'1 month 4 weeks',
$this
->createTimestamp('2013-10-12 10:09:08'),
$request_time,
),
array(
'1 month 4 weeks 2 days',
$this
->createTimestamp('2013-10-12 10:09:08'),
$request_time,
$granularity_3,
),
array(
'2 months',
$this
->createTimestamp('2013-10-11 10:09:08'),
$request_time,
),
array(
'2 months',
$this
->createTimestamp('2013-10-10 10:09:08'),
$request_time,
),
array(
'2 months',
$this
->createTimestamp('2013-10-09 08:07:06'),
$request_time,
),
array(
'2 months',
$this
->createTimestamp('2013-10-09 08:07:06'),
$request_time,
$granularity_3,
),
array(
'2 months',
$this
->createTimestamp('2013-10-09 08:07:06'),
$request_time,
$granularity_4,
),
array(
'6 months',
$this
->createTimestamp('2013-06-09 10:09:08'),
$request_time,
),
array(
'11 months',
$this
->createTimestamp('2013-01-11 07:09:08'),
$request_time,
),
array(
'11 months 4 weeks',
$this
->createTimestamp('2012-12-12 10:09:08'),
$request_time,
),
array(
'11 months 4 weeks 2 days',
$this
->createTimestamp('2012-12-12 10:09:08'),
$request_time,
$granularity_3,
),
// Checks for years and possibly months, days, hours, minutes or seconds.
array(
'1 year',
$this
->createTimestamp('2012-12-11 10:09:08'),
$request_time,
),
array(
'1 year',
$this
->createTimestamp('2012-12-11 10:08:08'),
$request_time,
),
array(
'1 year',
$this
->createTimestamp('2012-12-10 10:09:08'),
$request_time,
),
array(
'2 years',
$this
->createTimestamp('2011-12-11 10:09:08'),
$request_time,
),
array(
'2 years',
$this
->createTimestamp('2011-12-11 10:07:08'),
$request_time,
),
array(
'2 years',
$this
->createTimestamp('2011-12-09 10:09:08'),
$request_time,
),
array(
'2 years 2 months',
$this
->createTimestamp('2011-10-09 08:07:06'),
$request_time,
$granularity_3,
),
array(
'2 years 2 months',
$this
->createTimestamp('2011-10-09 08:07:06'),
$request_time,
$granularity_4,
),
array(
'10 years',
$this
->createTimestamp('2003-12-11 10:09:08'),
$request_time,
),
array(
'100 years',
$this
->createTimestamp('1913-12-11 10:09:08'),
$request_time,
),
// Checks the non-strict option vs. strict (default).
array(
'1 second',
$this
->createTimestamp('2013-12-11 10:09:08'),
$this
->createTimestamp('2013-12-11 10:09:07'),
$non_strict,
),
array(
'0 seconds',
$this
->createTimestamp('2013-12-11 10:09:08'),
$this
->createTimestamp('2013-12-11 10:09:07'),
),
// Checks granularity limit.
array(
'2 years 3 months 1 week',
$this
->createTimestamp('2011-08-30 11:15:57'),
$request_time,
$granularity_3,
),
);
return $data;
}