예제 #1
0
 public function testTranslatorMethods()
 {
     $translatorMock = $this->getMock('Zend\\I18n\\Translator\\Translator');
     $this->validator->setTranslator($translatorMock, 'foo');
     $this->assertEquals($translatorMock, $this->validator->getTranslator());
     $this->assertEquals('foo', $this->validator->getTranslatorTextDomain());
     $this->assertTrue($this->validator->hasTranslator());
     $this->assertTrue($this->validator->isTranslatorEnabled());
     $this->validator->setTranslatorEnabled(false);
     $this->assertFalse($this->validator->isTranslatorEnabled());
 }
예제 #2
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']);
 }