From 36d9fe7a3ba9bad9ee6b181a9cd38c6cbf774d3c Mon Sep 17 00:00:00 2001 From: Vlasta Vesely Date: Sun, 20 Aug 2017 16:54:51 +0200 Subject: [PATCH] tests: update (#164) --- tests/Forms/Forms.renderer.translate.phpt | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/Forms/Forms.renderer.translate.phpt b/tests/Forms/Forms.renderer.translate.phpt index 8afce201c..4d963273b 100644 --- a/tests/Forms/Forms.renderer.translate.phpt +++ b/tests/Forms/Forms.renderer.translate.phpt @@ -15,15 +15,20 @@ require __DIR__ . '/../bootstrap.php'; class Translator implements ITranslator { + public $counter = []; + + public function translate($message, $count = null) { + @$this->counter[$message]++; // @ intentionally return strtoupper($message); } } +$translator = new Translator; $form = new Form; -$form->setTranslator(new Translator); +$form->setTranslator($translator); $form->setAction('test'); $form->addError('Login failed'); @@ -38,3 +43,17 @@ $form->addSubmit('submit', 'Send'); Assert::matchFile(__DIR__ . '/Forms.renderer.translate.expect', $form->__toString(true)); + + +// Checking whether translation is not duplicated +Assert::same([ + 'Login failed' => 1, + 'Weak password' => 1, + 'Username' => 1, + 'or email' => 1, + 'Please enter your username' => 1, + 'Password' => 1, + 'This field is required.' => 1, + 'Minimal length is %d chars' => 1, + 'Send' => 1, +], $translator->counter);