Skip to content

Commit 9519002

Browse files
committed
testing tests v7
1 parent 9dcd0f5 commit 9519002

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

tests/TranslatorTest.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,31 @@
55

66
class TranslatorTest extends TestCase
77
{
8-
public function testTranslation()
8+
public function testHelloWorld()
99
{
1010
$translator = new Translator(dir: "./tests/locales/", lang: "en_US");
1111
$this->assertEquals('hello world', $translator->locale('testValues', 'helloWorld'));
1212
}
1313

14-
/*public function testInvalidLanguage()
15-
{
16-
$translator = new Translator(dir: "./locales/", lang: "en_US");
17-
$this->expectException(InvalidArgumentException::class);
18-
$translator->translate('Hello', 'invalid-lang');
19-
}*/
14+
public function testBasedOnNumber()
15+
{
16+
$translator = new Translator(dir: "./tests/locales/", lang: "en_US");
17+
$this->assertEquals('box', $translator->locale('testValues', 'BasedOnNumber', ['_counter' => 1]));
18+
$this->assertEquals('boxes', $translator->locale('testValues', 'BasedOnNumber', ['_counter' => 2]));
19+
$this->assertEquals('a lot of boxes', $translator->locale('testValues', 'BasedOnNumber', ['_counter' => 50]));
20+
}
21+
22+
public function testThxText()
23+
{
24+
$translator = new Translator(dir: "./tests/locales/", lang: "en_US");
25+
$this->assertEquals('Thank you John for buying a piece of apple', $translator->locale('testValues', 'thxText', ['username' => 'John', 'product' => 'apple']));
26+
}
27+
28+
public function testThxTextCounter()
29+
{
30+
$translator = new Translator(dir: "./tests/locales/", lang: "en_US");
31+
$this->assertEquals('Thank you John for buying a piece of apple', $translator->locale('testValues', 'thxTextCounter', ['username' => 'John', 'product' => 'apple', '_counter' => 1]));
32+
$this->assertEquals('Thank you John for buying two of apple', $translator->locale('testValues', 'thxTextCounter', ['username' => 'John', 'product' => 'apple', '_counter' => 2]));
33+
$this->assertEquals('Thank you John for buying 50 pieces of apple', $translator->locale('testValues', 'thxTextCounter', ['username' => 'John', 'product' => 'apple', '_counter' => 50]));
34+
}
2035
}

0 commit comments

Comments
 (0)