74
74
$this->assertEquals('OK', $translator->trans($msgid), '-> caching does not work in '.($debug ? 'debug' : 'production'));
77
public function testRefreshCacheWhenResourcesChange()
80
$loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
83
->will($this->returnValue($this->getCatalogue('fr', array(
88
$translator = new Translator('fr', null, $this->tmpDir, true);
89
$translator->setLocale('fr');
90
$translator->addLoader('loader', $loader);
91
$translator->addResource('loader', 'foo', 'fr');
93
$this->assertEquals('foo A', $translator->trans('foo'));
95
// add a new resource to refresh the cache
96
$loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
99
->will($this->returnValue($this->getCatalogue('fr', array(
104
$translator = new Translator('fr', null, $this->tmpDir, true);
105
$translator->setLocale('fr');
106
$translator->addLoader('loader', $loader);
107
$translator->addResource('loader', 'bar', 'fr');
109
$this->assertEquals('foo B', $translator->trans('foo'));
112
77
public function testCatalogueIsReloadedWhenResourcesAreNoLongerFresh()
154
119
* @dataProvider runForDebugAndProduction
156
public function testDifferentTranslatorsForSameLocaleDoNotInterfere($debug)
158
$locale = 'any_locale';
159
$format = 'some_format';
162
// Create a Translator and prime its cache
163
$translator = new Translator($locale, null, $this->tmpDir, $debug);
164
$translator->addLoader($format, new ArrayLoader());
165
$translator->addResource($format, array($msgid => 'FAIL'), $locale);
166
$translator->trans($msgid);
169
* Create another Translator with the same locale but a different resource.
170
* It should not use the first translator's cache but return the value from its own resource.
172
$translator = new Translator($locale, null, $this->tmpDir, $debug);
173
$translator->addLoader($format, new ArrayLoader());
174
$translator->addResource($format, array($msgid => 'OK'), $locale);
176
$this->assertEquals('OK', $translator->trans($msgid), '-> different translators for the same domain interfere in '.($debug ? 'debug' : 'production'));
180
* @dataProvider runForDebugAndProduction
182
121
public function testDifferentTranslatorsForSameLocaleDoNotOverwriteEachOthersCache($debug)