diff --git a/tests/I18nTest.php b/tests/I18nTest.php index 6b7a86a..208f844 100644 --- a/tests/I18nTest.php +++ b/tests/I18nTest.php @@ -232,7 +232,7 @@ public function testPluralTranslation(): void ' array("%nbr%" => ($context["nbr"] ?? null), ));', $generatedCode ); - $html = $template->render(['nbr' => 5]); + $html = $template->render(['nbr' => 5, 'nbr_persons' => 0]); $this->assertEquals('One person', $html); $this->assertNotEmpty($html); } @@ -258,7 +258,7 @@ public function testPluralTranslationWithComment(): void '// l10n: Number of users', $generatedCode ); - $html = $template->render(['nbr' => 5]); + $html = $template->render(['nbr' => 5, 'nbr_persons' => 0]); $this->assertEquals('one user likes this.', $html); $this->assertNotEmpty($html); } @@ -277,15 +277,13 @@ public function testSimplePluralTranslation(): void 'yield \Wdes\phpI18nL10n\Launcher::getPlugin()->ngettext("One person", "persons", abs( // line 1' . "\n" . '($context["a"] ?? null)));', $generatedCode ); - $html = $template->render(['nbr' => 5]); + $html = $template->render(['nbr' => 5, 'a' => 0]); $this->assertEquals('One person', $html); $this->assertNotEmpty($html); } /** * Test simple plural translation using count - - * @return void */ public function testSimplePluralTranslationCount(): void @@ -300,7 +298,7 @@ public function testSimplePluralTranslationCount(): void '($context["a"] ?? null), "count", [], "any", false, false, false, 1)));', $generatedCode ); - $html = $template->render(['a' => ['1', '2']]); + $html = $template->render(['a' => [1, 2]]); $this->assertEquals('One person', $html); $this->assertNotEmpty($html); } @@ -323,7 +321,7 @@ public function testSimplePluralTranslationCountAndVars(): void ' $this->source, ($context["a"] ?? null), "count", [], "any", false, false, false, 1)), ));', $generatedCode ); - $html = $template->render(['a' => ['1', '2'], 'nbrdogs' => 3]); + $html = $template->render(['a' => [1, 2], 'nbrdogs' => 3]); $this->assertEquals('One person', $html); $this->assertNotEmpty($html); } diff --git a/tests/I18nTestNoData.php b/tests/I18nTestNoData.php index 978d327..3beca65 100644 --- a/tests/I18nTestNoData.php +++ b/tests/I18nTestNoData.php @@ -39,7 +39,6 @@ class I18nTestNoData extends TestCase /** * Set up the instance * - * @return void */ public function setUp(): void { @@ -56,7 +55,6 @@ public function setUp(): void /** * Test simple translation using get and set - * @return void */ public function testSimpleTranslationGetSetTranslations(): void { @@ -90,7 +88,6 @@ public function testSimpleTranslationGetSetTranslations(): void /** * Test simple translation - * @return void */ public function testSimpleTranslation(): void { @@ -104,7 +101,6 @@ public function testSimpleTranslation(): void /** * Test simple translation with a comment - * @return void */ public function testSimpleTranslationWithComment(): void { @@ -118,7 +114,6 @@ public function testSimpleTranslationWithComment(): void /** * Test simple translation with context - * @return void */ public function testSimpleTranslationWithContext(): void { @@ -132,7 +127,6 @@ public function testSimpleTranslationWithContext(): void /** * Test simple translation with context and a variable - * @return void */ public function testSimpleTranslationWithContextAndVariable(): void { @@ -150,7 +144,6 @@ public function testSimpleTranslationWithContextAndVariable(): void /** * Test simple translation with context and some variables - * @return void */ public function testSimpleTranslationWithContextAndVariables(): void { @@ -169,43 +162,40 @@ public function testSimpleTranslationWithContextAndVariables(): void /** * Test plural translation - * @return void */ public function testPluralTranslation(): void { $template = $this->twig->createTemplate( '{% trans %}One person{% plural nbr_persons %}{{ nbr }} persons{% endtrans %}' ); - $html = $template->render(['nbr' => 5]); + $html = $template->render(['nbr' => 5, 'nbr_persons' => 0]); $this->assertEquals('One person', $html); $this->assertNotEmpty($html); } /** * Test plural translation with comment - * @return void */ public function testPluralTranslationWithComment(): void { $template = $this->twig->createTemplate( '{% trans %}one user likes this.{% plural nbr_persons %}{{ nbr }} users likes this.{% notes %}Number of users{% endtrans %}' ); - $html = $template->render(['nbr' => 5]); + $html = $template->render(['nbr' => 5, 'nbr_persons' => 0]); $this->assertEquals('one user likes this.', $html); $this->assertNotEmpty($html); } /** * Test simple plural translation - * @return void */ public function testSimplePluralTranslation(): void { $template = $this->twig->createTemplate( - '{% trans %}One person{% plural a %}persons{% endtrans %}' + '{% trans %}One person{% plural nbr %}persons{% endtrans %}' ); $html = $template->render(['nbr' => 5]); - $this->assertEquals('One person', $html); + $this->assertEquals('persons', $html); $this->assertNotEmpty($html); } @@ -220,28 +210,26 @@ public function testSimplePluralTranslationCount(): void $template = $this->twig->createTemplate( '{% trans %}One person{% plural a.count %}persons{% endtrans %}' ); - $html = $template->render(['a' => ['1', '2']]); + $html = $template->render(['a' => [1, 2]]); $this->assertEquals('One person', $html); $this->assertNotEmpty($html); } /** * Test simple plural translation using count and vars - * @return void */ public function testSimplePluralTranslationCountAndVars(): void { $template = $this->twig->createTemplate( - '{% trans %}One person{% plural a.count %}persons and {{ count }} dogs{% endtrans %}' + '{% trans %}One person{% plural a.count %}persons and {{ nbrdogs }} dogs{% endtrans %}' ); - $html = $template->render(['a' => ['1', '2'], 'nbrdogs' => 3]); + $html = $template->render(['a' => [1, 2], 'nbrdogs' => 3]); $this->assertEquals('One person', $html); $this->assertNotEmpty($html); } /** * Test simple plural translation using count and vars - * @return void */ public function testExtensionI18nGetName(): void {