diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index deaca9c2e2..5c2ab2c9cc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -78,6 +78,8 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase // do it another time as the cache is primed now $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface'); + $loader->expects($this->never())->method('load'); + $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir)); $translator->setLocale('fr'); $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); @@ -91,6 +93,27 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz')); $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); + + // refresh cache again when resource file resources file change + $resource = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface'); + $resource + ->expects($this->at(0)) + ->method('isFresh') + ->will($this->returnValue(false)) + ; + $catalogue = $this->getCatalogue('fr', array('foo' => 'foo fresh')); + $catalogue->addResource($resource); + + $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface'); + $loader + ->expects($this->at(0)) + ->method('load') + ->will($this->returnValue($catalogue)) + ; + + $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir)); + $translator->setLocale('fr'); + $this->assertEquals('foo fresh', $translator->trans('foo')); } public function testTransWithCachingWithInvalidLocale()