From c8e8945efbac31605b6cb80723992b8bfdbd259c Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Mon, 13 Oct 2014 17:44:57 +0200 Subject: implement localizations based on punic --- tests/lib/l10n.php | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/lib/l10n.php b/tests/lib/l10n.php index 5ddf2290c35..26ad87b60f6 100644 --- a/tests/lib/l10n.php +++ b/tests/lib/l10n.php @@ -52,17 +52,59 @@ class Test_L10n extends PHPUnit_Framework_TestCase { $this->assertEquals('5 oken', (string)$l->n('%n window', '%n windows', 5)); } + public function localizationDataProvider() { + return array( + // timestamp as string + array('February 13, 2009 at 11:31:30 PM GMT+0', 'en', 'datetime', '1234567890'), + array('13. Februar 2009 um 23:31:30 GMT+0', 'de', 'datetime', '1234567890'), + array('February 13, 2009', 'en', 'date', '1234567890'), + array('13. Februar 2009', 'de', 'date', '1234567890'), + array('11:31:30 PM GMT+0', 'en', 'time', '1234567890'), + array('23:31:30 GMT+0', 'de', 'time', '1234567890'), + + // timestamp as int + array('February 13, 2009 at 11:31:30 PM GMT+0', 'en', 'datetime', 1234567890), + array('13. Februar 2009 um 23:31:30 GMT+0', 'de', 'datetime', 1234567890), + array('February 13, 2009', 'en', 'date', 1234567890), + array('13. Februar 2009', 'de', 'date', 1234567890), + array('11:31:30 PM GMT+0', 'en', 'time', 1234567890), + array('23:31:30 GMT+0', 'de', 'time', 1234567890), + + // DateTime object + array('February 13, 2009 at 11:31:30 PM GMT+0', 'en', 'datetime', new DateTime('@1234567890')), + array('13. Februar 2009 um 23:31:30 GMT+0', 'de', 'datetime', new DateTime('@1234567890')), + array('February 13, 2009', 'en', 'date', new DateTime('@1234567890')), + array('13. Februar 2009', 'de', 'date', new DateTime('@1234567890')), + array('11:31:30 PM GMT+0', 'en', 'time', new DateTime('@1234567890')), + array('23:31:30 GMT+0', 'de', 'time', new DateTime('@1234567890')), + ); + } + /** - * Issue #4360: Do not call strtotime() on numeric strings. + * @dataProvider localizationDataProvider */ - public function testNumericStringToDateTime() { + public function testNumericStringLocalization($expectedDate, $lang, $type, $value) { $l = new OC_L10N('test'); - $this->assertSame('February 13, 2009 23:31', $l->l('datetime', '1234567890')); + $l->forceLanguage($lang); + $this->assertSame($expectedDate, $l->l($type, $value)); + } + + public function firstDayDataProvider() { + return array( + array(1, 'de'), + array(0, 'en'), + ); } - public function testNumericToDateTime() { + /** + * @dataProvider firstDayDataProvider + * @param $expected + * @param $lang + */ + public function testFirstWeekDay($expected, $lang) { $l = new OC_L10N('test'); - $this->assertSame('February 13, 2009 23:31', $l->l('datetime', 1234567890)); + $l->forceLanguage($lang); + $this->assertSame($expected, $l->l('firstday', 'firstday')); } /** -- cgit v1.2.3 From a359fe7e6a7e43c2253aeca96b594dc25bece3d9 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Fri, 17 Oct 2014 10:50:46 +0200 Subject: adding unit tests for en_GB and en-GB - just to verify --- tests/lib/l10n.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/lib/l10n.php b/tests/lib/l10n.php index 26ad87b60f6..a97fa22f05c 100644 --- a/tests/lib/l10n.php +++ b/tests/lib/l10n.php @@ -77,6 +77,14 @@ class Test_L10n extends PHPUnit_Framework_TestCase { array('13. Februar 2009', 'de', 'date', new DateTime('@1234567890')), array('11:31:30 PM GMT+0', 'en', 'time', new DateTime('@1234567890')), array('23:31:30 GMT+0', 'de', 'time', new DateTime('@1234567890')), + + // en_GB + array('13 February 2009 at 23:31:30 GMT+0', 'en_GB', 'datetime', new DateTime('@1234567890')), + array('13 February 2009', 'en_GB', 'date', new DateTime('@1234567890')), + array('23:31:30 GMT+0', 'en_GB', 'time', new DateTime('@1234567890')), + array('13 February 2009 at 23:31:30 GMT+0', 'en-GB', 'datetime', new DateTime('@1234567890')), + array('13 February 2009', 'en-GB', 'date', new DateTime('@1234567890')), + array('23:31:30 GMT+0', 'en-GB', 'time', new DateTime('@1234567890')), ); } -- cgit v1.2.3 From 69db442c4981baf895625017558d70408c61e269 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Tue, 21 Oct 2014 16:05:35 +0200 Subject: fixing expected values for formatDate() unit tests --- tests/lib/util.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/lib/util.php b/tests/lib/util.php index 600b794d8b8..9a3185b3f79 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -29,7 +29,7 @@ class Test_Util extends PHPUnit_Framework_TestCase { date_default_timezone_set("UTC"); $result = OC_Util::formatDate(1350129205); - $expected = 'October 13, 2012 11:53'; + $expected = 'October 13, 2012 at 11:53:25 AM GMT+0'; $this->assertEquals($expected, $result); $result = OC_Util::formatDate(1102831200, true); @@ -41,7 +41,7 @@ class Test_Util extends PHPUnit_Framework_TestCase { date_default_timezone_set("UTC"); $result = OC_Util::formatDate(1350129205, false, 'Europe/Berlin'); - $expected = 'October 13, 2012 13:53'; + $expected = 'October 13, 2012 at 1:53:25 PM GMT+0'; $this->assertEquals($expected, $result); } @@ -57,7 +57,7 @@ class Test_Util extends PHPUnit_Framework_TestCase { \OC::$server->getSession()->set('timezone', 3); $result = OC_Util::formatDate(1350129205, false); - $expected = 'October 13, 2012 14:53'; + $expected = 'October 13, 2012 at 2:53:25 PM GMT+0'; $this->assertEquals($expected, $result); } -- cgit v1.2.3