Skip to content

Commit

Permalink
test translating flash messages with Phrase objects in template
Browse files Browse the repository at this point in the history
[Closes #124]
  • Loading branch information
fprochazka committed May 15, 2017
1 parent c8a8819 commit 6659181
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/KdybyTests/Translation/TranslateMacros.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace KdybyTests\Translation;

use Kdyby;
use Kdyby\Translation\Phrase;
use Nette;
use Latte;
use Tester;
Expand Down Expand Up @@ -141,6 +142,31 @@ front.missingKey.namedHelloCounting' . "\n", $template->__toString());



public function testPhraseInFlashMessage()
{
$template = $this->buildTemplate();
$template->setFile(__DIR__ . '/files/flashMessage.latte');
$template->setParameters([
'flashes' => unserialize(serialize([
(object) [
'message' => new Phrase('front.flashes.weSentPasswordRequest', ['email' => 'filip@prochazka.su']),
'type' => 'info',
],
(object) [
'message' => new Phrase('front.weSentPasswordRequest', ['email' => 'filip@prochazka.su']),
'type' => 'info',
],
])),
]);

$expected = "\tHeslo vám bylo zasláno na email filip@prochazka.su\n" .
"\tHeslo vám pošleme na email filip@prochazka.su\n\n";

Assert::match($expected, $template->__toString());
}



/**
* @return \Nette\Bridges\ApplicationLatte\Template
*/
Expand Down
3 changes: 3 additions & 0 deletions tests/KdybyTests/Translation/files/flashMessage.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{foreach $flashes as $flash}
{_$flash->message}
{/foreach}
4 changes: 4 additions & 0 deletions tests/KdybyTests/Translation/lang/front.cs_CZ.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ noescape:

orderForm:
useCredits: Použít %count% kredit|Použít %count% kredity|Použít %count% kreditů

flashes:
weSentPasswordRequest: "Heslo vám bylo zasláno na email %email%"
weSentPasswordRequest: "Heslo vám pošleme na email %email%"

0 comments on commit 6659181

Please sign in to comment.