summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2021-04-22 21:20:16 +0200
committerGitHub <noreply@github.com>2021-04-22 21:20:16 +0200
commit012f791c8f1603ca5906ec8247b3320c94708e00 (patch)
tree91c35b3c23bd849448538f649cc8cdc97802511f /tests
parent6d25c3c7fe2e42438ade6b1cf7e12ab7668fe811 (diff)
parent79ebc7f24c9c908efb5b41422150bca9cf0b7966 (diff)
downloadnextcloud-server-012f791c8f1603ca5906ec8247b3320c94708e00.tar.gz
nextcloud-server-012f791c8f1603ca5906ec8247b3320c94708e00.zip
Merge pull request #26375 from nextcloud/techdebt/noid/symfony-component-translation-pluralization-rules-is-deprecated
"Symfony\Component\Translation\PluralizationRules" is deprecated
Diffstat (limited to 'tests')
-rw-r--r--tests/data/l10n/de.json5
-rw-r--r--tests/lib/L10N/L10nTest.php21
-rw-r--r--tests/lib/Share20/ManagerTest.php6
3 files changed, 30 insertions, 2 deletions
diff --git a/tests/data/l10n/de.json b/tests/data/l10n/de.json
index c2b6f34c081..d9e75d303c5 100644
--- a/tests/data/l10n/de.json
+++ b/tests/data/l10n/de.json
@@ -1,6 +1,9 @@
{
"translations" : {
- "_%n file_::_%n files_": ["%n Datei", "%n Dateien"]
+ "_%n file_::_%n files_": ["%n Datei", "%n Dateien"],
+ "Ordered placeholders one %s two %s": "Placeholder one %s two %s",
+ "Reordered placeholders one %s two %s": "Placeholder two %2$s one %1$s",
+ "Reordered placeholders one %1$s two %2$s": "Placeholder two %2$s one %1$s"
},
"pluralForm" : "nplurals=2; plural=(n != 1);"
}
diff --git a/tests/lib/L10N/L10nTest.php b/tests/lib/L10N/L10nTest.php
index 0de09386fba..3fb22b3f66e 100644
--- a/tests/lib/L10N/L10nTest.php
+++ b/tests/lib/L10N/L10nTest.php
@@ -76,6 +76,27 @@ class L10nTest extends TestCase {
$this->assertEquals('5 oken', (string)$l->n('%n window', '%n windows', 5));
}
+ public function dataPlaceholders(): array {
+ return [
+ ['Ordered placeholders one %s two %s', 'Placeholder one 1 two 2'],
+ ['Reordered placeholders one %s two %s', 'Placeholder two 2 one 1'],
+ ['Reordered placeholders one %1$s two %2$s', 'Placeholder two 2 one 1'],
+ ];
+ }
+
+ /**
+ * @dataProvider dataPlaceholders
+ *
+ * @param $string
+ * @param $expected
+ */
+ public function testPlaceholders($string, $expected): void {
+ $transFile = \OC::$SERVERROOT.'/tests/data/l10n/de.json';
+ $l = new L10N($this->getFactory(), 'test', 'de', 'de_AT', [$transFile]);
+
+ $this->assertEquals($expected, $l->t($string, ['1', '2']));
+ }
+
public function localizationData() {
return [
// timestamp as string
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index e17f179b600..a4dd621522d 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -126,6 +126,10 @@ class ManagerTest extends \Test\TestCase {
->willReturnCallback(function ($text, $parameters = []) {
return vsprintf($text, $parameters);
});
+ $this->l->method('n')
+ ->willReturnCallback(function ($singular, $plural, $count, $parameters = []) {
+ return vsprintf(str_replace('%n', $count, ($count === 1) ? $singular : $plural), $parameters);
+ });
$this->factory = new DummyFactory(\OC::$server);
@@ -1957,7 +1961,7 @@ class ManagerTest extends \Test\TestCase {
$data = [];
// No exclude groups
- $data[] = ['no', null, null, null, false];
+ $data[] = ['no', null, null, [], false];
// empty exclude list, user no groups
$data[] = ['yes', '', json_encode(['']), [], false];