summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-10-23 16:09:47 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-10-23 16:09:47 +0200
commite26a16afea14df7428dd614906fc94521538dfe3 (patch)
treee5c6f7acc4c4f1cea119d43884037c9dd0cd0697 /tests
parent770f643e5cf78493dde576f85fee9c4b66a31f38 (diff)
parentfa9a7442005e66d73923a88ad905f21eb714291f (diff)
downloadnextcloud-server-e26a16afea14df7428dd614906fc94521538dfe3.tar.gz
nextcloud-server-e26a16afea14df7428dd614906fc94521538dfe3.zip
Merge pull request #11549 from owncloud/add-more-localizations-master
implement localizations based on punic
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/l10n.php60
-rw-r--r--tests/lib/util.php6
2 files changed, 58 insertions, 8 deletions
diff --git a/tests/lib/l10n.php b/tests/lib/l10n.php
index 5ddf2290c35..a97fa22f05c 100644
--- a/tests/lib/l10n.php
+++ b/tests/lib/l10n.php
@@ -52,17 +52,67 @@ 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')),
+
+ // 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')),
+ );
+ }
+
/**
- * 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'));
}
/**
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);
}