diff options
Diffstat (limited to 'tests/lib/DateTimeFormatterTest.php')
-rw-r--r-- | tests/lib/DateTimeFormatterTest.php | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/tests/lib/DateTimeFormatterTest.php b/tests/lib/DateTimeFormatterTest.php index 924cac9d399..cfab1643beb 100644 --- a/tests/lib/DateTimeFormatterTest.php +++ b/tests/lib/DateTimeFormatterTest.php @@ -36,23 +36,23 @@ class DateTimeFormatterTest extends TestCase { $this->formatter = new \OC\DateTimeFormatter(new \DateTimeZone('UTC'), \OCP\Util::getL10N('lib', 'en')); } - protected function getTimestampAgo($time, $seconds = 0, $minutes = 0, $hours = 0, $days = 0, $years = 0) { + protected static function getTimestampAgo($time, $seconds = 0, $minutes = 0, $hours = 0, $days = 0, $years = 0) { return $time - $seconds - $minutes * 60 - $hours * 3600 - $days * 24 * 3600 - $years * 365 * 24 * 3600; } - public function formatTimeSpanData() { + public static function formatTimeSpanData(): array { $time = 1416916800; // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo $deL10N = \OCP\Util::getL10N('lib', 'de'); return [ ['seconds ago', $time, $time], ['in a few seconds', $time + 5 , $time], - ['1 minute ago', $this->getTimestampAgo($time, 30, 1), $time], - ['15 minutes ago', $this->getTimestampAgo($time, 30, 15), $time], - ['in 15 minutes', $time, $this->getTimestampAgo($time, 30, 15)], - ['1 hour ago', $this->getTimestampAgo($time, 30, 15, 1), $time], - ['3 hours ago', $this->getTimestampAgo($time, 30, 15, 3), $time], - ['in 3 hours', $time, $this->getTimestampAgo($time, 30, 15, 3)], - ['4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4), $time], + ['1 minute ago', self::getTimestampAgo($time, 30, 1), $time], + ['15 minutes ago', self::getTimestampAgo($time, 30, 15), $time], + ['in 15 minutes', $time, self::getTimestampAgo($time, 30, 15)], + ['1 hour ago', self::getTimestampAgo($time, 30, 15, 1), $time], + ['3 hours ago', self::getTimestampAgo($time, 30, 15, 3), $time], + ['in 3 hours', $time, self::getTimestampAgo($time, 30, 15, 3)], + ['4 days ago', self::getTimestampAgo($time, 30, 15, 3, 4), $time], ['seconds ago', new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], ['seconds ago', new \DateTime('Wed, 02 Oct 2013 23:59:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], @@ -81,29 +81,29 @@ class DateTimeFormatterTest extends TestCase { $this->assertEquals((string)$expected, (string)$this->formatter->formatTimeSpan($timestamp, $compare, $locale)); } - public function formatDateSpanData() { + public static function formatDateSpanData(): array { $time = 1416916800; // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo $deL10N = \OCP\Util::getL10N('lib', 'de'); return [ // Normal testing - ['today', $this->getTimestampAgo($time, 30, 15), $time], - ['yesterday', $this->getTimestampAgo($time, 0, 0, 0, 1), $time], - ['tomorrow', $time, $this->getTimestampAgo($time, 0, 0, 0, 1)], - ['4 days ago', $this->getTimestampAgo($time, 0, 0, 0, 4), $time], - ['in 4 days', $time, $this->getTimestampAgo($time, 0, 0, 0, 4)], - ['5 months ago', $this->getTimestampAgo($time, 0, 0, 0, 155), $time], - ['next month', $time, $this->getTimestampAgo($time, 0, 0, 0, 32)], - ['in 5 months', $time, $this->getTimestampAgo($time, 0, 0, 0, 155)], - ['2 years ago', $this->getTimestampAgo($time, 0, 0, 0, 0, 2), $time], - ['next year', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 1)], - ['in 2 years', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 2)], + ['today', self::getTimestampAgo($time, 30, 15), $time], + ['yesterday', self::getTimestampAgo($time, 0, 0, 0, 1), $time], + ['tomorrow', $time, self::getTimestampAgo($time, 0, 0, 0, 1)], + ['4 days ago', self::getTimestampAgo($time, 0, 0, 0, 4), $time], + ['in 4 days', $time, self::getTimestampAgo($time, 0, 0, 0, 4)], + ['5 months ago', self::getTimestampAgo($time, 0, 0, 0, 155), $time], + ['next month', $time, self::getTimestampAgo($time, 0, 0, 0, 32)], + ['in 5 months', $time, self::getTimestampAgo($time, 0, 0, 0, 155)], + ['2 years ago', self::getTimestampAgo($time, 0, 0, 0, 0, 2), $time], + ['next year', $time, self::getTimestampAgo($time, 0, 0, 0, 0, 1)], + ['in 2 years', $time, self::getTimestampAgo($time, 0, 0, 0, 0, 2)], // Test with compare timestamp - ['today', $this->getTimestampAgo($time, 0, 0, 0, 0, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)], - ['yesterday', $this->getTimestampAgo($time, 30, 15, 3, 1, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)], - ['4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)], - ['5 months ago', $this->getTimestampAgo($time, 30, 15, 3, 155, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)], - ['2 years ago', $this->getTimestampAgo($time, 30, 15, 3, 35, 3), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)], + ['today', self::getTimestampAgo($time, 0, 0, 0, 0, 1), self::getTimestampAgo($time, 0, 0, 0, 0, 1)], + ['yesterday', self::getTimestampAgo($time, 30, 15, 3, 1, 1), self::getTimestampAgo($time, 0, 0, 0, 0, 1)], + ['4 days ago', self::getTimestampAgo($time, 30, 15, 3, 4, 1), self::getTimestampAgo($time, 0, 0, 0, 0, 1)], + ['5 months ago', self::getTimestampAgo($time, 30, 15, 3, 155, 1), self::getTimestampAgo($time, 0, 0, 0, 0, 1)], + ['2 years ago', self::getTimestampAgo($time, 30, 15, 3, 35, 3), self::getTimestampAgo($time, 0, 0, 0, 0, 1)], // Test translations [$deL10N->t('today'), new \DateTime('Wed, 02 Oct 2013 12:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N], @@ -147,7 +147,7 @@ class DateTimeFormatterTest extends TestCase { $this->assertEquals((string)$expected, (string)$this->formatter->formatDateSpan($timestamp, $compare, $locale)); } - public function formatDateData() { + public static function formatDateData(): array { return [ [1102831200, 'December 12, 2004'], ]; @@ -160,7 +160,7 @@ class DateTimeFormatterTest extends TestCase { $this->assertEquals($expected, (string)$this->formatter->formatDate($timestamp)); } - public function formatDateTimeData() { + public static function formatDateTimeData(): array { return [ [1350129205, null, "October 13, 2012, 11:53:25\xE2\x80\xAFAM UTC"], [1350129205, new \DateTimeZone('Europe/Berlin'), "October 13, 2012, 1:53:25\xE2\x80\xAFPM GMT+2"], |