public function TranslatorCacheTest::testThatACacheIsUsed in Plug 7
@dataProvider runForDebugAndProduction
File
- lib/
Symfony/ translation/ Tests/ TranslatorCacheTest.php, line 58
Class
Namespace
Symfony\Component\Translation\TestsCode
public function testThatACacheIsUsed($debug) {
$locale = 'any_locale';
$format = 'some_format';
$msgid = 'test';
// Prime the cache
$translator = new Translator($locale, null, $this->tmpDir, $debug);
$translator
->addLoader($format, new ArrayLoader());
$translator
->addResource($format, array(
$msgid => 'OK',
), $locale);
$translator
->trans($msgid);
// Try again and see we get a valid result whilst no loader can be used
$translator = new Translator($locale, null, $this->tmpDir, $debug);
$translator
->addLoader($format, $this
->createFailingLoader());
$translator
->addResource($format, array(
$msgid => 'OK',
), $locale);
$this
->assertEquals('OK', $translator
->trans($msgid), '-> caching does not work in ' . ($debug ? 'debug' : 'production'));
}