8000 [2.3][Translation] test refresh cache when resources File change. by aitboudad · Pull Request #14279 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[2.3][Translation] test refresh cache when resources File change. #14279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public function testTransWithCaching()

// do it another time as the cache is primed now
$loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
$loader->expects($this->never())->method('load');

$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir));
$translator->setLocale('fr');
$translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin'));
Expand All @@ -91,6 +93,27 @@ public function testTransWithCaching()
$this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1));
$this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz'));
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));

// refresh cache again when resource file resources file change
$resource = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
$resource
->expects($this->at(0))
->method('isFresh')
->will($this->returnValue(false))
;
$catalogue = $this->getCatalogue('fr', array('foo' => 'foo fresh'));
$catalogue->addResource($resource);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabbuh haven't looked at it in detail, but I think this resource mock has no effect. Instead the resource already serialized in the cache will be loaded (and still be fresh)?


$loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
$loader
->expects($this->at(0))
->method('load')
->will($this->returnValue($catalogue))
;

$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir));
$translator->setLocale('fr');
$this->assertEquals('foo fresh', $translator->trans('foo'));
}

public function testTransWithCachingWithInvalidLocale()
Expand Down
0