From c4636e1252e992d038c24c361b87b7af99553fc3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 22 Aug 2013 08:57:44 +0200 Subject: [PATCH] added a functional test for locale handling in sub-requests --- .../TestBundle/Controller/FragmentController.php | 12 ++++++++++-- .../Tests/Functional/FragmentTest.php | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php index 54ebb27cb0..cefa7de7c1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php @@ -17,7 +17,7 @@ use Symfony\Component\DependencyInjection\ContainerAware; class FragmentController extends ContainerAware { - public function indexAction() + public function indexAction(Request $request) { $actions = $this->container->get('templating')->get('actions'); @@ -32,7 +32,10 @@ class FragmentController extends ContainerAware $html3 = $actions->render($actions->controller('TestBundle:Fragment:customlocale', array('_locale' => 'es'))); - return new Response($html1.'--'.$html2.'--'.$html3); + $request->setLocale('fr'); + $html4 = $actions->render($actions->controller('TestBundle:Fragment:forwardlocale')); + + return new Response($html1.'--'.$html2.'--'.$html3.'--'.$html4); } public function inlinedAction($options, $_format) @@ -49,6 +52,11 @@ class FragmentController extends ContainerAware { return new Response($request->getLocale()); } + + public function forwardLocaleAction(Request $request) + { + return new Response($request->getLocale()); + } } class Bar diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php index 14a30a684f..eafe6bd43e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php @@ -28,7 +28,7 @@ class FragmentTest extends WebTestCase $client->request('GET', '/fragment_home'); - $this->assertEquals('bar txt--html--es', $client->getResponse()->getContent()); + $this->assertEquals('bar txt--html--es--fr', $client->getResponse()->getContent()); } public function getConfigs()