php - Functional testing multilanguage Symfony2 app -


i trying test multilanguage app. have 4 languages form in application. try test indexaction(), when crawler go through page want check count of title, title can in english or in japanese example. when pass translation key not work. here code:

$this->assertequals(1, $crawler->filter('html:contains("logo_text")')->count()); 

so question is, can pass translation key tests? or need somehow hardcode value?

you can try solution florian eckerstorfer: https://florian.ec/articles/use-translation-keys-in-symfony2-functional-tests/

it creates new translator return key instead of real translation.

class notranslator implements translatorinterface {   public function trans($id, array $parameters = array(), $domain = null, $locale = null)   {     return $id;   } ... } 

and registering it:

# app/config/config_test.yml parameters:     translator.class: acme\demobundle\translation\translator\notranslator 

the blog post describes possibility of using compiler passes. lot more complex solution can start 1 above.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -