functional tests in Silex for language switch
The problem is that in the tests the langauge wont switch, on the website is does well.
So the tests fail.

I have this routing:

    $app->before(function () use ($app) {

            if ($locale = $app['request']->get('locale')) {
                $app['locale'] = $locale;
            }
		...
        }); 
    $app->get('/{locale}/index', function () use ($app) {
                return $app['twig']->render('index.twig');
        })->assert('locale',implode('|', $app['languages']));
        
    $app->get('/{locale}', function () use ($app) {
                return  $app->redirect("/".$app['locale']."/index");
        })->assert('locale',implode('|', $app['languages']));

The test is so:

    public function testLanguageRoutes(){
        $client = $this->createClient();
	$client->followRedirects();
        $crawler = $client->request('GET', '/de');
        $this->assertTrue($client->getResponse()->isOk());
        $this->assertTrue($crawler->filter('html:contains("Kopf")')->count() > 0);
	$crawler = $client->request('GET', '/de/index');
        $this->assertTrue($client->getResponse()->isOk());
        $this->assertTrue($crawler->filter('html:contains("Kopf")')->count() > 0);
        $crawler = $client->request('GET', '/fr');
        $this->assertTrue($client->getResponse()->isOk());
        //TODO not working, still returns de should return fr
        var_dump($crawler->text());
        $this->assertTrue($crawler->filter('html:contains("Pied")')->count() > 0);
	$crawler = $client->request('GET', '/aa');
        $this->assertTrue($client->getResponse()->isNotFound());
    }

Here the switch to french wont work, *$crawler->text()* still shows the german text.

Do I have to create one Test for each language?
That wont test the langauge switch really, in my opinion.

What is common way to test a scenario like that?
functional tests in Silex for language switch
===

The problem is that in the tests the langauge wont switch, on the website is does well.
So the tests fail.

I have this routing:

    $app->before(function () use ($app) {

            if ($locale = $app['request']->get('locale')) {
                $app['locale'] = $locale;
            }
		...
        }); 
    $app->get('/{locale}/index', function () use ($app) {
                return $app['twig']->render('index.twig');
        })->assert('locale',implode('|', $app['languages']));
        
    $app->get('/{locale}', function () use ($app) {
                return  $app->redirect("/".$app['locale']."/index");
        })->assert('locale',implode('|', $app['languages']));

The test is so:

    public function testLanguageRoutes(){
        $client = $this->createClient();
	$client->followRedirects();
        $crawler = $client->request('GET', '/de');
        $this->assertTrue($client->getResponse()->isOk());
        $this->assertTrue($crawler->filter('html:contains("Kopf")')->count() > 0);
	$crawler = $client->request('GET', '/de/index');
        $this->assertTrue($client->getResponse()->isOk());
        $this->assertTrue($crawler->filter('html:contains("Kopf")')->count() > 0);
        $crawler = $client->request('GET', '/fr');
        $this->assertTrue($client->getResponse()->isOk());
        //TODO not working, still returns de should return fr
        var_dump($crawler->text());
        $this->assertTrue($crawler->filter('html:contains("Pied")')->count() > 0);
	$crawler = $client->request('GET', '/aa');
        $this->assertTrue($client->getResponse()->isNotFound());
    }

Here the switch to french wont work, *$crawler->text()* still shows the german text.

Do I have to create one Test for each language?
That wont test the langauge switch really, in my opinion.

What is common way to test a scenario like that?