public function TranslatorCacheTest::testDifferentTranslatorsForSameLocaleDoNotOverwriteEachOthersCache in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/translation/Tests/TranslatorCacheTest.php \Symfony\Component\Translation\Tests\TranslatorCacheTest::testDifferentTranslatorsForSameLocaleDoNotOverwriteEachOthersCache()
@dataProvider runForDebugAndProduction
File
- vendor/
symfony/ translation/ Tests/ TranslatorCacheTest.php, line 121
Class
Namespace
Symfony\Component\Translation\TestsCode
public function testDifferentTranslatorsForSameLocaleDoNotOverwriteEachOthersCache($debug) {
/*
* Similar to the previous test. After we used the second translator, make
* sure there's still a useable cache for the first one.
*/
$locale = 'any_locale';
$format = 'some_format';
$msgid = 'test';
// Create a Translator and prime its cache
$translator = new Translator($locale, null, $this->tmpDir, $debug);
$translator
->addLoader($format, new ArrayLoader());
$translator
->addResource($format, array(
$msgid => 'OK',
), $locale);
$translator
->trans($msgid);
// Create another Translator with a different catalogue for the same locale
$translator = new Translator($locale, null, $this->tmpDir, $debug);
$translator
->addLoader($format, new ArrayLoader());
$translator
->addResource($format, array(
$msgid => 'FAIL',
), $locale);
$translator
->trans($msgid);
// Now the first translator must still have a useable cache.
$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), '-> the cache was overwritten by another translator instance in ' . ($debug ? 'debug' : 'production'));
}