You are here

public function TranslatorCacheTest::testRefreshCacheWhenResourcesAreNoLongerFresh in Plug 7

File

lib/Symfony/translation/Tests/TranslatorCacheTest.php, line 229

Class

TranslatorCacheTest

Namespace

Symfony\Component\Translation\Tests

Code

public function testRefreshCacheWhenResourcesAreNoLongerFresh() {
  $resource = $this
    ->getMock('Symfony\\Component\\Config\\Resource\\ResourceInterface');
  $loader = $this
    ->getMock('Symfony\\Component\\Translation\\Loader\\LoaderInterface');
  $resource
    ->method('isFresh')
    ->will($this
    ->returnValue(false));
  $loader
    ->expects($this
    ->exactly(2))
    ->method('load')
    ->will($this
    ->returnValue($this
    ->getCatalogue('fr', array(), array(
    $resource,
  ))));

  // prime the cache
  $translator = new Translator('fr', null, $this->tmpDir, true);
  $translator
    ->addLoader('loader', $loader);
  $translator
    ->addResource('loader', 'foo', 'fr');
  $translator
    ->trans('foo');

  // prime the cache second time
  $translator = new Translator('fr', null, $this->tmpDir, true);
  $translator
    ->addLoader('loader', $loader);
  $translator
    ->addResource('loader', 'foo', 'fr');
  $translator
    ->trans('foo');
}