summaryrefslogtreecommitdiff
path: root/tests/Unit/Helpers/Translation
diff options
context:
space:
mode:
authorLuca <Luca@hackerspace-bamberg.de>2019-10-25 09:33:09 +0200
committerLuca <Luca@hackerspace-bamberg.de>2019-10-28 14:25:31 +0100
commit6cde313e47cd08216ff15d733c8de894f2657a8b (patch)
tree21158b5c4ba3b84307f5c946d5dcffa20cd828f1 /tests/Unit/Helpers/Translation
parentd10fe2336671905c8529095c896031a56dbe1b29 (diff)
Move translations whose message ids do not appear as literals in the sources into a separate file
Test whether additional.{m,p}o files are loaded correctly
Diffstat (limited to 'tests/Unit/Helpers/Translation')
-rw-r--r--tests/Unit/Helpers/Translation/Assets/ba_RR/additional.po3
-rw-r--r--tests/Unit/Helpers/Translation/Assets/fo_OO/additional.mobin0 -> 93 bytes
-rw-r--r--tests/Unit/Helpers/Translation/Assets/fo_OO/additional.po3
-rw-r--r--tests/Unit/Helpers/Translation/TranslationServiceProviderTest.php7
4 files changed, 11 insertions, 2 deletions
diff --git a/tests/Unit/Helpers/Translation/Assets/ba_RR/additional.po b/tests/Unit/Helpers/Translation/Assets/ba_RR/additional.po
new file mode 100644
index 00000000..72383947
--- /dev/null
+++ b/tests/Unit/Helpers/Translation/Assets/ba_RR/additional.po
@@ -0,0 +1,3 @@
+# Testing content
+msgid "validation.foo.bar"
+msgstr "B Arr required!"
diff --git a/tests/Unit/Helpers/Translation/Assets/fo_OO/additional.mo b/tests/Unit/Helpers/Translation/Assets/fo_OO/additional.mo
new file mode 100644
index 00000000..73faf3ba
--- /dev/null
+++ b/tests/Unit/Helpers/Translation/Assets/fo_OO/additional.mo
Binary files differ
diff --git a/tests/Unit/Helpers/Translation/Assets/fo_OO/additional.po b/tests/Unit/Helpers/Translation/Assets/fo_OO/additional.po
new file mode 100644
index 00000000..8eea7df9
--- /dev/null
+++ b/tests/Unit/Helpers/Translation/Assets/fo_OO/additional.po
@@ -0,0 +1,3 @@
+# Testing content
+msgid "validation.foo.bar"
+msgstr "Foo Bar required!"
diff --git a/tests/Unit/Helpers/Translation/TranslationServiceProviderTest.php b/tests/Unit/Helpers/Translation/TranslationServiceProviderTest.php
index e55fdf02..8c9e21b8 100644
--- a/tests/Unit/Helpers/Translation/TranslationServiceProviderTest.php
+++ b/tests/Unit/Helpers/Translation/TranslationServiceProviderTest.php
@@ -7,6 +7,7 @@ use Engelsystem\Helpers\Translation\TranslationServiceProvider;
use Engelsystem\Helpers\Translation\Translator;
use Engelsystem\Test\Unit\ServiceProviderTest;
use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\MockObject\Rule\InvokedCount;
use Symfony\Component\HttpFoundation\Session\Session;
class TranslationServiceProviderTest extends ServiceProviderTest
@@ -82,11 +83,12 @@ class TranslationServiceProviderTest extends ServiceProviderTest
$app = $this->getApp(['get']);
$serviceProvider = new TranslationServiceProvider($app);
- $this->setExpects($app, 'get', ['path.lang'], __DIR__ . '/Assets');
+ $this->setExpects($app, 'get', ['path.lang'], __DIR__ . '/Assets', new InvokedCount(2));
// Get translator
$translator = $serviceProvider->getTranslator('fo_OO');
$this->assertEquals('Foo Bar!', $translator->gettext('foo.bar'));
+ $this->assertEquals('Foo Bar required!', $translator->gettext('validation.foo.bar'));
// Retry from cache
$serviceProvider->getTranslator('fo_OO');
@@ -99,12 +101,13 @@ class TranslationServiceProviderTest extends ServiceProviderTest
public function testGetTranslatorFromPo(): void
{
$app = $this->getApp(['get']);
- $this->setExpects($app, 'get', ['path.lang'], __DIR__ . '/Assets');
+ $this->setExpects($app, 'get', ['path.lang'], __DIR__ . '/Assets', new InvokedCount(2));
$serviceProvider = new TranslationServiceProvider($app);
// Get translator using a .po file
$translator = $serviceProvider->getTranslator('ba_RR');
$this->assertEquals('B Arr!', $translator->gettext('foo.bar'));
+ $this->assertEquals('B Arr required!', $translator->gettext('validation.foo.bar'));
}
}