You are here

public function TranslatorCacheTest::testDifferentCacheFilesAreUsedForDifferentSetsOfFallbackLocales in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/translation/Tests/TranslatorCacheTest.php \Symfony\Component\Translation\Tests\TranslatorCacheTest::testDifferentCacheFilesAreUsedForDifferentSetsOfFallbackLocales()

File

vendor/symfony/translation/Tests/TranslatorCacheTest.php, line 151

Class

TranslatorCacheTest

Namespace

Symfony\Component\Translation\Tests

Code

public function testDifferentCacheFilesAreUsedForDifferentSetsOfFallbackLocales() {

  /*
   * Because the cache file contains a catalogue including all of its fallback
   * catalogues, we must take the set of fallback locales into consideration when
   * loading a catalogue from the cache.
   */
  $translator = new Translator('a', null, $this->tmpDir);
  $translator
    ->setFallbackLocales(array(
    'b',
  ));
  $translator
    ->addLoader('array', new ArrayLoader());
  $translator
    ->addResource('array', array(
    'foo' => 'foo (a)',
  ), 'a');
  $translator
    ->addResource('array', array(
    'bar' => 'bar (b)',
  ), 'b');
  $this
    ->assertEquals('bar (b)', $translator
    ->trans('bar'));

  // Remove fallback locale
  $translator
    ->setFallbackLocales(array());
  $this
    ->assertEquals('bar', $translator
    ->trans('bar'));

  // Use a fresh translator with no fallback locales, result should be the same
  $translator = new Translator('a', null, $this->tmpDir);
  $translator
    ->addLoader('array', new ArrayLoader());
  $translator
    ->addResource('array', array(
    'foo' => 'foo (a)',
  ), 'a');
  $translator
    ->addResource('array', array(
    'bar' => 'bar (b)',
  ), 'b');
  $this
    ->assertEquals('bar', $translator
    ->trans('bar'));
}