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:
commit
08c2f44a96
|
@ -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()
|
||||
|
|
Reference in New Issue