From 95190024156a49158f98a7f9bdcbe321ab02a4de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20B=C4=9Blsk=C3=BD?= Date: Wed, 11 Dec 2024 20:07:28 +0000 Subject: [PATCH] testing tests v7 --- tests/TranslatorTest.php | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/tests/TranslatorTest.php b/tests/TranslatorTest.php index 6615064..5d0b397 100644 --- a/tests/TranslatorTest.php +++ b/tests/TranslatorTest.php @@ -5,16 +5,31 @@ class TranslatorTest extends TestCase { - public function testTranslation() + public function testHelloWorld() { $translator = new Translator(dir: "./tests/locales/", lang: "en_US"); $this->assertEquals('hello world', $translator->locale('testValues', 'helloWorld')); } - /*public function testInvalidLanguage() - { - $translator = new Translator(dir: "./locales/", lang: "en_US"); - $this->expectException(InvalidArgumentException::class); - $translator->translate('Hello', 'invalid-lang'); - }*/ + public function testBasedOnNumber() + { + $translator = new Translator(dir: "./tests/locales/", lang: "en_US"); + $this->assertEquals('box', $translator->locale('testValues', 'BasedOnNumber', ['_counter' => 1])); + $this->assertEquals('boxes', $translator->locale('testValues', 'BasedOnNumber', ['_counter' => 2])); + $this->assertEquals('a lot of boxes', $translator->locale('testValues', 'BasedOnNumber', ['_counter' => 50])); + } + + public function testThxText() + { + $translator = new Translator(dir: "./tests/locales/", lang: "en_US"); + $this->assertEquals('Thank you John for buying a piece of apple', $translator->locale('testValues', 'thxText', ['username' => 'John', 'product' => 'apple'])); + } + + public function testThxTextCounter() + { + $translator = new Translator(dir: "./tests/locales/", lang: "en_US"); + $this->assertEquals('Thank you John for buying a piece of apple', $translator->locale('testValues', 'thxTextCounter', ['username' => 'John', 'product' => 'apple', '_counter' => 1])); + $this->assertEquals('Thank you John for buying two of apple', $translator->locale('testValues', 'thxTextCounter', ['username' => 'John', 'product' => 'apple', '_counter' => 2])); + $this->assertEquals('Thank you John for buying 50 pieces of apple', $translator->locale('testValues', 'thxTextCounter', ['username' => 'John', 'product' => 'apple', '_counter' => 50])); + } } \ No newline at end of file