Skip to content

Instantly share code, notes, and snippets.

@inri13666
Created September 28, 2016 12:08
Show Gist options
  • Save inri13666/0a9cfd875dbf5379eb5f4bfd4ce41916 to your computer and use it in GitHub Desktop.
Save inri13666/0a9cfd875dbf5379eb5f4bfd4ce41916 to your computer and use it in GitHub Desktop.
public function testRebuildCache()
{
$translator = $this->getContainer()->get('translator.default');
$key = uniqid('TRANSLATION_KEY_', true);
$domain = LoadTranslations::TRANSLATION_KEY_DOMAIN;
$locale = LoadLanguages::LANGUAGE2;
$expectedValue = uniqid('TEST_VALUE_', true) . '';
$this->manager->saveValue($key, $expectedValue, $locale, $domain);
$this->manager->flush();
//Ensure that catalog still contains old translated value
$actualValue = $translator->trans($key, [], $domain, $locale);
$this->assertNotEquals($expectedValue, $actualValue);
$this->manager->rebuildCache();
//Ensure that catalog now contains new translated value
$actualValue = $translator->trans($key, [], $domain, $locale);
$this->assertEquals((string)$expectedValue, (string)$actualValue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment