ulogger-server/.tests/tests/LangTest.php

44 lines
1.3 KiB
PHP
Raw Normal View History

2019-02-25 10:04:09 +01:00
<?php
use PHPUnit\Framework\TestCase;
2020-02-20 17:08:47 +01:00
if (!defined("ROOT_DIR")) { define("ROOT_DIR", __DIR__ . "/../.."); }
2019-02-25 10:04:09 +01:00
require_once(__DIR__ . "/../../helpers/config.php");
require_once(__DIR__ . "/../../helpers/lang.php");
class LangTest extends TestCase {
2020-02-20 17:08:47 +01:00
protected $mockConfig;
public function setUp() {
parent::setUp();
$this->mockConfig = new uConfig(false);
}
2019-02-25 10:04:09 +01:00
public function testGetLanguages() {
$languages = uLang::getLanguages();
$this->assertNotEmpty($languages);
$this->assertArrayHasKey("en", $languages);
$this->assertArrayHasKey("pl", $languages);
$this->assertEquals("English", $languages["en"]);
$this->assertEquals("Polski", $languages["pl"]);
}
public function testGetStrings() {
2020-02-20 17:08:47 +01:00
$lang = new uLang($this->mockConfig);
2019-02-25 10:04:09 +01:00
$this->assertEquals("User", $lang->getStrings()["user"]);
2020-02-20 17:08:47 +01:00
$this->mockConfig->lang = "pl";
$lang = new uLang($this->mockConfig);
2019-02-25 10:04:09 +01:00
$this->assertEquals("Użytkownik", $lang->getStrings()["user"]);
}
public function testGetSetupStrings() {
2020-02-20 17:08:47 +01:00
$lang = new uLang($this->mockConfig);
2019-02-25 10:04:09 +01:00
$this->assertEquals("Congratulations!", $lang->getSetupStrings()["congratulations"]);
2020-02-20 17:08:47 +01:00
$this->mockConfig->lang = "pl";
$lang = new uLang($this->mockConfig);
2019-02-25 10:04:09 +01:00
$this->assertEquals("Gratulacje!", $lang->getSetupStrings()["congratulations"]);
}
}
?>