I want to do a functional test with Symfony2 to check if a users profile is displayed and if a form is working:
namespace Dbe\DDBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class ProfileControllerTest extends WebTestCase {
public function testNewsletterOnOff(){
// Create a new client to browse the application
$client = static::createClient();
$client->request('GET', '/', array(), array(), array(
'HTTP_ACCEPT_LANGUAGE' => 'en',
));
$crawler = $client->request('GET', '/en/profile/');
After executing the test in the console: phpunit -c app I get the following error message:
There was 1 error:
1) Dbe\DDBundle\Tests\Controller\ProfileControllerTest::testNewsletterOnOff
Undefined index: HTTP_ACCEPT_LANGUAGE
I guess this error comes up because a Controller is checking the browsers language. So how can I fake the HTTP_ACCEPT_LANGUAGE in functional tests with symfony? Thanks in advance for the help!