Esempio n. 1
0
 public function testCanDisableTranslator()
 {
     $loader = new TestAsset\ArrayTranslator();
     $loader->translations = array('%value% was passed' => 'This is the translated message for %value%');
     $translator = new Translator();
     $translator->getPluginManager()->setService('default', $loader);
     $translator->addTranslationFile('default', null);
     $this->validator->setTranslator($translator);
     $this->assertFalse($this->validator->isValid('bar'));
     $messages = $this->validator->getMessages();
     $this->assertTrue(array_key_exists('fooMessage', $messages));
     $this->assertContains('bar', $messages['fooMessage']);
     $this->assertContains('This is the translated message for ', $messages['fooMessage']);
     $this->validator->setTranslatorDisabled(true);
     $this->assertTrue($this->validator->isTranslatorDisabled());
     $this->assertFalse($this->validator->isValid('bar'));
     $messages = $this->validator->getMessages();
     $this->assertTrue(array_key_exists('fooMessage', $messages));
     $this->assertContains('bar', $messages['fooMessage']);
     $this->assertContains('bar was passed', $messages['fooMessage']);
 }