Skip to content

Commit

Permalink
translator macro test
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleš committed May 20, 2019
1 parent 02259c8 commit b097ddf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions tests/lang/messages.en_US.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ hi: "Hi %name%!"
apples: "{0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples"
depth:
message: "Depth message"
very:
very:
depth:
message: "Very very depth message"
"": "Empty string key"
8 changes: 5 additions & 3 deletions tests/tests/Translator.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,14 @@ class Translator extends Contributte\Translation\Tests\AbstractTest
Tester\Assert::same('Hi Ales!', $template->renderToString(Tester\FileMock::create('{php $message = "hi"}{$message|translate: null, [name => Ales], messages, en}')));

Tester\Assert::same('Depth message', $template->renderToString(Tester\FileMock::create('{_messages.depth.message}')));
Tester\Assert::same('Depth message', $template->renderToString(Tester\FileMock::create('{translator messages}{_depth.message}{/translator}')));
Tester\Assert::same('Depth message', $template->renderToString(Tester\FileMock::create('{translator messages}{translator depth}{_message}{/translator}{/translator}')));
Tester\Assert::exception(function () use ($template): void {$template->renderToString(Tester\FileMock::create('{translator}{_depth.message}{/translator}'));}, \Latte\CompileException::class);

Tester\Assert::same('missing.translation', $template->renderToString(Tester\FileMock::create('{_messages.missing.translation}')));
Tester\Assert::same('missing.translation', $template->renderToString(Tester\FileMock::create('{php $message = "messages.missing.translation"}{$message|translate}')));

Tester\Assert::same('Depth message', $template->renderToString(Tester\FileMock::create('{translator messages}{_depth.message}{/translator}')));
Tester\Assert::same('Very very depth message', $template->renderToString(Tester\FileMock::create('{translator messages}{translator messages.very.very.depth}{_message}{/translator}{/translator}')));
Tester\Assert::same('Depth message-Very very depth message-Depth message', $template->renderToString(Tester\FileMock::create('{translator messages}{_depth.message}{translator messages.very.very.depth}-{_message}-{/translator}{_depth.message}{/translator}')));
Tester\Assert::exception(function () use ($template): void {$template->renderToString(Tester\FileMock::create('{translator}{_depth.message}{/translator}'));}, \Latte\CompileException::class);
};

$template->createTemplate();
Expand Down

0 comments on commit b097ddf

Please sign in to comment.