Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2017-07-05 19:02:16 +0300
committerGeorg Ehrke <developer@georgehrke.com>2018-06-27 14:17:43 +0300
commit93011579fe27624ed746b54f1094da556d019f5a (patch)
tree3938ac102ebab50a521d7a8e0f2f14c297b5d20a /tests/lib/L10N
parentea380b2918b298259f7f45a3e4671f50d89e6c13 (diff)
Add tests
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'tests/lib/L10N')
-rw-r--r--tests/lib/L10N/L10nTest.php76
1 files changed, 39 insertions, 37 deletions
diff --git a/tests/lib/L10N/L10nTest.php b/tests/lib/L10N/L10nTest.php
index 703aa9e227c..dece334a9bd 100644
--- a/tests/lib/L10N/L10nTest.php
+++ b/tests/lib/L10N/L10nTest.php
@@ -38,7 +38,7 @@ class L10nTest extends TestCase {
public function testGermanPluralTranslations() {
$transFile = \OC::$SERVERROOT.'/tests/data/l10n/de.json';
- $l = new L10N($this->getFactory(), 'test', 'de', [$transFile]);
+ $l = new L10N($this->getFactory(), 'test', 'de', 'de_AT', [$transFile]);
$this->assertEquals('1 Datei', (string) $l->n('%n file', '%n files', 1));
$this->assertEquals('2 Dateien', (string) $l->n('%n file', '%n files', 2));
@@ -46,7 +46,7 @@ class L10nTest extends TestCase {
public function testRussianPluralTranslations() {
$transFile = \OC::$SERVERROOT.'/tests/data/l10n/ru.json';
- $l = new L10N($this->getFactory(), 'test', 'ru', [$transFile]);
+ $l = new L10N($this->getFactory(), 'test', 'ru', 'ru_UA',[$transFile]);
$this->assertEquals('1 файл', (string)$l->n('%n file', '%n files', 1));
$this->assertEquals('2 файла', (string)$l->n('%n file', '%n files', 2));
@@ -70,7 +70,7 @@ class L10nTest extends TestCase {
public function testCzechPluralTranslations() {
$transFile = \OC::$SERVERROOT.'/tests/data/l10n/cs.json';
- $l = new L10N($this->getFactory(), 'test', 'cs', [$transFile]);
+ $l = new L10N($this->getFactory(), 'test', 'cs', 'cs_CZ', [$transFile]);
$this->assertEquals('1 okno', (string)$l->n('%n window', '%n windows', 1));
$this->assertEquals('2 okna', (string)$l->n('%n window', '%n windows', 2));
@@ -80,51 +80,51 @@ class L10nTest extends TestCase {
public function localizationData() {
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'),
+ array('February 13, 2009 at 11:31:30 PM GMT+0', 'en', 'en_US', 'datetime', '1234567890'),
+ array('13. Februar 2009 um 23:31:30 GMT+0', 'de', 'de_DE', 'datetime', '1234567890'),
+ array('February 13, 2009', 'en', 'en_US', 'date', '1234567890'),
+ array('13. Februar 2009', 'de', 'de_DE', 'date', '1234567890'),
+ array('11:31:30 PM GMT+0', 'en', 'en_US', 'time', '1234567890'),
+ array('23:31:30 GMT+0', 'de', 'de_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),
+ array('February 13, 2009 at 11:31:30 PM GMT+0', 'en', 'en_US', 'datetime', 1234567890),
+ array('13. Februar 2009 um 23:31:30 GMT+0', 'de', 'de_DE', 'datetime', 1234567890),
+ array('February 13, 2009', 'en', 'en_US', 'date', 1234567890),
+ array('13. Februar 2009', 'de', 'de_DE', 'date', 1234567890),
+ array('11:31:30 PM GMT+0', 'en', 'en_US', 'time', 1234567890),
+ array('23:31:30 GMT+0', 'de', 'de_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')),
+ array('February 13, 2009 at 11:31:30 PM GMT+0', 'en', 'en_US', 'datetime', new DateTime('@1234567890')),
+ array('13. Februar 2009 um 23:31:30 GMT+0', 'de', 'de_DE', 'datetime', new DateTime('@1234567890')),
+ array('February 13, 2009', 'en', 'en_US', 'date', new DateTime('@1234567890')),
+ array('13. Februar 2009', 'de', 'de_DE', 'date', new DateTime('@1234567890')),
+ array('11:31:30 PM GMT+0', 'en', 'en_US', 'time', new DateTime('@1234567890')),
+ array('23:31:30 GMT+0', 'de', 'de_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')),
+ array('13 February 2009 at 23:31:30 GMT+0', 'en_GB', 'en_GB', 'datetime', new DateTime('@1234567890')),
+ array('13 February 2009', 'en_GB', 'en_GB', 'date', new DateTime('@1234567890')),
+ array('23:31:30 GMT+0', 'en_GB', 'en_GB', 'time', new DateTime('@1234567890')),
+ array('13 February 2009 at 23:31:30 GMT+0', 'en-GB', 'en_GB', 'datetime', new DateTime('@1234567890')),
+ array('13 February 2009', 'en-GB', 'en_GB', 'date', new DateTime('@1234567890')),
+ array('23:31:30 GMT+0', 'en-GB', 'en_GB', 'time', new DateTime('@1234567890')),
);
}
/**
* @dataProvider localizationData
*/
- public function testNumericStringLocalization($expectedDate, $lang, $type, $value) {
- $l = new L10N($this->getFactory(), 'test', $lang, []);
+ public function testNumericStringLocalization($expectedDate, $lang, $locale, $type, $value) {
+ $l = new L10N($this->getFactory(), 'test', $lang, $locale, []);
$this->assertSame($expectedDate, $l->l($type, $value));
}
public function firstDayData() {
return array(
- array(1, 'de'),
- array(0, 'en'),
+ array(1, 'de', 'de_DE'),
+ array(0, 'en', 'en_US'),
);
}
@@ -132,16 +132,17 @@ class L10nTest extends TestCase {
* @dataProvider firstDayData
* @param $expected
* @param $lang
+ * @param $locale
*/
- public function testFirstWeekDay($expected, $lang) {
- $l = new L10N($this->getFactory(), 'test', $lang, []);
+ public function testFirstWeekDay($expected, $lang, $locale) {
+ $l = new L10N($this->getFactory(), 'test', $lang, $locale, []);
$this->assertSame($expected, $l->l('firstday', 'firstday'));
}
public function jsDateData() {
return array(
- array('dd.MM.yy', 'de'),
- array('M/d/yy', 'en'),
+ array('dd.MM.yy', 'de', 'de_DE'),
+ array('M/d/yy', 'en', 'en_US'),
);
}
@@ -149,9 +150,10 @@ class L10nTest extends TestCase {
* @dataProvider jsDateData
* @param $expected
* @param $lang
+ * @param $locale
*/
- public function testJSDate($expected, $lang) {
- $l = new L10N($this->getFactory(), 'test', $lang, []);
+ public function testJSDate($expected, $lang, $locale) {
+ $l = new L10N($this->getFactory(), 'test', $lang, $locale, []);
$this->assertSame($expected, $l->l('jsdate', 'jsdate'));
}