Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[2.3][Translation] test refresh cache when resources File change.
  • Loading branch information
aitboudad committed Apr 9, 2015
1 parent 986e3d1 commit 4d01fab
Showing 1 changed file with 23 additions and 0 deletions.
Expand Up @@ -78,6 +78,8 @@ public function testTransWithCaching()

// 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'));
Expand All @@ -91,6 +93,27 @@ public function testTransWithCaching()
$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()
Expand Down

0 comments on commit 4d01fab

Please sign in to comment.