minor #14279 [2.3][Translation] test refresh cache when resources File change. (aitboudad)

This PR was merged into the 2.3 branch.

Discussion
----------

[2.3][Translation] test refresh cache when resources File change.

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Fixed tickets  | ~
| Tests pass?   | yes
| License       | MIT

For 2.6 https://github.com/symfony/symfony/pull/14280

Commits
-------

4d01fab [2.3][Translation] test refresh cache when resources File change.
This commit is contained in:
Abdellatif Ait boudad 2015-04-09 19:30:45 +01:00
commit 08c2f44a96
1 changed files with 23 additions and 0 deletions

View File

@ -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()