You are here

public function TranslatorCacheTest::testThatACacheIsUsed in Zircon Profile 8

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

@dataProvider runForDebugAndProduction

File

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

Class

TranslatorCacheTest

Namespace

Symfony\Component\Translation\Tests

Code

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'));
}