Functional Testing And I18N (Goutte)


While writing first functional tests using Goutte I’ve stumbled upon problem with internationalization.

// pseudocode

public function testDummy()


    $crawler = $client->request('GET', 'login');

    // here user logs in, and sets different than default application language, lets say PL

    $title = $crawler->filter('title')->text(); // has value "Title (PL)"

    $this->assertEquals(Yii::t('app','Title (EN)'), $title);


    //leads to: Failed asserting that "Title (PL)" equals "Title (EN)".


HTML returned by crawler is in PL (as it should be), but language in test function is application_default, what messes everything up. As I understand problem, method Yii::t() in test function, and second one inside HTML template works in different scopes.

But I have no idea what to do about it :) Should I force yii to use default language in tests, or is there more friendly way?

Thanks for any suggestions.

After further tinkering I decided simply not to test in different locales. Workarounds I came up with are too complicated and not worth the effort (for example add custom http header with language to every server response).