summaryrefslogtreecommitdiff
path: root/tests/units/Core
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-11-15 20:43:14 -0500
committerFrederic Guillot <fred@kanboard.net>2016-11-15 20:43:14 -0500
commit94cd5869bf9e4b86063cbb71777a05525b9d5c52 (patch)
tree65e6992a365df91262262d095893a7e2f01e6c89 /tests/units/Core
parentebb6b2827d0496303852f524a551592295dd0040 (diff)
Do not load translations from a relative path
When the application is installed outside of the document root, loading translations will not work.
Diffstat (limited to 'tests/units/Core')
-rw-r--r--tests/units/Core/TranslatorTest.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/units/Core/TranslatorTest.php b/tests/units/Core/TranslatorTest.php
new file mode 100644
index 00000000..6aa480e1
--- /dev/null
+++ b/tests/units/Core/TranslatorTest.php
@@ -0,0 +1,45 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Kanboard\Core\Translator;
+
+class TranslatorTest extends Base
+{
+ public function setUp()
+ {
+ parent::setUp();
+ Translator::unload();
+ }
+
+ public function testLoading()
+ {
+ $translator = new Translator();
+ $this->assertSame('Yes', $translator->translate('Yes'));
+
+ Translator::load('fr_FR');
+ $this->assertSame('Oui', $translator->translate('Yes'));
+
+ Translator::unload();
+ $this->assertSame('Yes', $translator->translate('Yes'));
+
+ Translator::load('de_DE', Translator::getDefaultFolder());
+ $this->assertSame('Ja', $translator->translate('Yes'));
+ }
+
+ public function testNumberFormatting()
+ {
+ $translator = new Translator();
+ $this->assertSame('1,024.42', $translator->number(1024.42));
+
+ Translator::load('fr_FR');
+ $this->assertSame('1 024,42', $translator->number(1024.42));
+ }
+
+ public function testTranslateEscaping()
+ {
+ $translator = new Translator();
+ $this->assertSame('&lt;b&gt;', $translator->translate('<b>'));
+ $this->assertSame('<b>', $translator->translateNoEscaping('<b>'));
+ }
+}