Skip to content

Commit 88de103

Browse files
committed
[2.3][Translation] test refresh cache when resources File change.
1 parent 02afee7 commit 88de103

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Tests/Translation/TranslatorTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public function testTransWithCaching()
7878

7979
// do it another time as the cache is primed now
8080
$loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
81+
$loader->expects($this->never())->method('load');
82+
8183
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir));
8284
$translator->setLocale('fr');
8385
$translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin'));
@@ -91,6 +93,27 @@ public function testTransWithCaching()
9193
$this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1));
9294
$this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz'));
9395
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));
96+
97+
// refresh cache again when resource file resources file change
98+
$resource = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
99+
$resource
100+
->expects($this->at(0))
101+
->method('isFresh')
102+
->will($this->returnValue(false))
103+
;
104+
$catalogue = $this->getCatalogue('fr', array('foo' => 'foo fresh'));
105+
$catalogue->addResource($resource);
106+
107+
$loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
108+
$loader
109+
->expects($this->at(0))
110+
->method('load')
111+
->will($this->returnValue($catalogue))
112+
;
113+
114+
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir));
115+
$translator->setLocale('fr');
116+
$this->assertEquals('foo fresh', $translator->trans('foo'));
94117
}
95118

96119
public function testTransWithCachingWithInvalidLocale()

0 commit comments

Comments
 (0)