Skip to content

Commit

Permalink
testing tests v7
Browse files Browse the repository at this point in the history
  • Loading branch information
wUFr committed Dec 11, 2024
1 parent 9dcd0f5 commit 9519002
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions tests/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
}
}

0 comments on commit 9519002

Please sign in to comment.