| 1 common.test | public CommonFormatDateTestCase::providerTestFormatDiff() |
Data provider for testFormatDiff().
File
- core/
modules/ simpletest/ tests/ common.test, line 3071 - Tests for common.inc functionality.
Class
- CommonFormatDateTestCase
- Tests the format_date() function.
Code
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_xx = array('langcode' => self::LANGCODE);
$non_strict = array('strict' => FALSE);
$data = array(
// Checks for equal timestamps.
array('0 sec', $request_time, $request_time, array(),),
// Checks for seconds only.
array(
'1 sec', $this->createTimestamp('2013-12-11 10:09:07'),
$request_time, array(),
),
array(
'1 sec', $this->createTimestamp('2013-12-11 10:09:07'),
$request_time, array(),
),
array(
'1 sec', $this->createTimestamp('2013-12-11 10:09:07'),
$request_time, $granularity_3 + $langcode_en,
),
array(
'1 sec', $this->createTimestamp('2013-12-11 10:09:07'),
$request_time, $granularity_4 + $langcode_xx,
),
array(
'2 sec', $this->createTimestamp('2013-12-11 10:09:06'),
$request_time, array(),
),
array(
'59 sec', $this->createTimestamp('2013-12-11 10:08:09'),
$request_time, array(),
),
array(
'59 sec', $this->createTimestamp('2013-12-11 10:08:09'),
$request_time, array(),
),
// Checks for minutes and possibly seconds.
array(
'1 min', $this->createTimestamp('2013-12-11 10:08:08'),
$request_time, array(),
),
array(
'1 min', $this->createTimestamp('2013-12-11 10:08:08'),
$request_time, array(),
),
array(
'1 min 1 sec', $this->createTimestamp('2013-12-11 10:08:07'),
$request_time, array(),
),
array(
'1 min 59 sec', $this->createTimestamp('2013-12-11 10:07:09'),
$request_time, array(),
),
array(
'2 min', $this->createTimestamp('2013-12-11 10:07:08'),
$request_time, array(),
),
array(
'2 min 1 sec', $this->createTimestamp('2013-12-11 10:07:07'),
$request_time, array(),
),
array(
'2 min 2 sec', $this->createTimestamp('2013-12-11 10:07:06'),
$request_time, array(),
),
array(
'2 min 2 sec', $this->createTimestamp('2013-12-11 10:07:06'),
$request_time, $granularity_3,
),
array(
'2 min 2 sec', $this->createTimestamp('2013-12-11 10:07:06'),
$request_time, $granularity_4,
),
array(
'30 min', $this->createTimestamp('2013-12-11 09:39:08'),
$request_time, array(),
),
array(
'59 min 59 sec', $this->createTimestamp('2013-12-11 09:09:09'),
$request_time, array(),
),
array(
'59 min 59 sec', $this->createTimestamp('2013-12-11 09:09:09'),
$request_time, array(),
),
// Checks for hours and possibly minutes or seconds.
array(
'1 hour', $this->createTimestamp('2013-12-11 09:09:08'),
$request_time, array(),
),
array(
'1 hour', $this->createTimestamp('2013-12-11 09:09:08'),
$request_time, array(),
),
array(
'1 hour', $this->createTimestamp('2013-12-11 09:09:07'),
$request_time, array(),
),
array(
'1 hour', $this->createTimestamp('2013-12-11 09:09:06'),
$request_time, array(),
),
array(
'1 hour 1 min', $this->createTimestamp('2013-12-11 09:08:08'),
$request_time, array(),
),
array(
'1 hour 1 min 1 sec', $this->createTimestamp('2013-12-11 09:08:07'),
$request_time, $granularity_3,
),
array(
'1 hour 1 min 2 sec', $this->createTimestamp('2013-12-11 09:08:06'),
$request_time, $granularity_4,
),
array(
'1 hour 30 min', $this->createTimestamp('2013-12-11 08:39:08'),
$request_time, array(),
),
array(
'2 hours', $this->createTimestamp('2013-12-11 08:09:08'),
$request_time, array(),
),
array(
'23 hours 59 min', $this->createTimestamp('2013-12-10 10:10:08'),
$request_time, array(),
),
// Checks for days and possibly hours, minutes or seconds.
array(
'1 day', $this->createTimestamp('2013-12-10 10:09:08'),
$request_time, array(),
),
array(
'1 day', $this->createTimestamp('2013-12-10 10:09:07'),
$request_time, array(),
),
array(
'1 day 1 hour', $this->createTimestamp('2013-12-10 09:09:08'),
$request_time, array(),
),
array(
'1 day 1 hour 1 min', $this->createTimestamp('2013-12-10 09:08:07'),
$request_time, $granularity_3 + $langcode_en,
),
array(
'1 day 1 hour 1 min 1 sec',
$this->createTimestamp('2013-12-10 09:08:07'),
$request_time, $granularity_4 + $langcode_xx,
),
array(
'1 day 2 hours 2 min 2 sec',
$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(),
),
array(
'2 days', $this->createTimestamp('2013-12-09 10:07:08'),
$request_time, array(),
),
array(
'2 days 2 hours', $this->createTimestamp('2013-12-09 08:09:08'),
$request_time, array(),),
array(
'2 days 2 hours 2 min', $this->createTimestamp('2013-12-09 08:07:06'),
$request_time, $granularity_3 + $langcode_en,
),
array(
'2 days 2 hours 2 min 2 sec',
$this->createTimestamp('2013-12-09 08:07:06'),
$request_time, $granularity_4 + $langcode_xx,
),
// Checks for weeks and possibly days, hours, minutes or seconds.
array(
'1 week', $this->createTimestamp('2013-12-04 10:09:08'),
$request_time, array(),
),
array(
'1 week 1 day', $this->createTimestamp('2013-12-03 10:09:08'),
$request_time, array(),
),
array(
'2 weeks', $this->createTimestamp('2013-11-27 10:09:08'),
$request_time, array(),
),
array(
'2 weeks 2 days', $this->createTimestamp('2013-11-25 08:07:08'),
$request_time, array(),
),
array(
'2 weeks 2 days 2 hours 2 min',
$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(),
),
array(
'4 weeks 1 day', $this->createTimestamp('2013-11-12 10:09:08'),
$request_time, array(),
),
// Checks for months and possibly days, hours, minutes or seconds.
array(
'1 month', $this->createTimestamp('2013-11-11 10:09:08'),
$request_time, array(),
),
array(
'1 month', $this->createTimestamp('2013-11-11 10:09:07'),
$request_time, array(),
),
array(
'1 month', $this->createTimestamp('2013-11-11 09:09:08'),
$request_time, array(),
),
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(),
),
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(),
),
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(),
),
array(
'2 months', $this->createTimestamp('2013-10-10 10:09:08'),
$request_time, array(),
),
array(
'2 months', $this->createTimestamp('2013-10-09 08:07:06'),
$request_time, array(),
),
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(),
),
array(
'11 months', $this->createTimestamp('2013-01-11 07:09:08'),
$request_time, array(),
),
array(
'11 months 4 weeks', $this->createTimestamp('2012-12-12 10:09:08'),
$request_time, array(),
),
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(),
),
array(
'1 year', $this->createTimestamp('2012-12-11 10:08:08'),
$request_time, array(),
),
array(
'1 year', $this->createTimestamp('2012-12-10 10:09:08'),
$request_time, array(),
),
array(
'2 years', $this->createTimestamp('2011-12-11 10:09:08'),
$request_time, array(),
),
array(
'2 years', $this->createTimestamp('2011-12-11 10:07:08'),
$request_time, array(),
),
array(
'2 years', $this->createTimestamp('2011-12-09 10:09:08'),
$request_time, array(),
),
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(),
),
array(
'100 years', $this->createTimestamp('1913-12-11 10:09:08'),
$request_time, array(),
),
// Checks the non-strict option vs. strict (default).
array(
'1 sec', $this->createTimestamp('2013-12-11 10:09:08'),
$this->createTimestamp('2013-12-11 10:09:07'), $non_strict,
),
array(
'0 sec', $this->createTimestamp('2013-12-11 10:09:08'),
$this->createTimestamp('2013-12-11 10:09:07'), array(),
),
// Checks granularity limit.
array(
'2 years 3 months 1 week', $this->createTimestamp('2011-08-30 11:15:57'),
$request_time, $granularity_3,
),
);
return $data;
}