I am creating some functional tests to test my controller. I have 2 functions at the moment. 1 for loggin in and 1 for the entity life cycle.
both should run normally (
After some searching I found the answer here on stackoverflow.
The symfony2 crawler, by default, guesses that the location of server is at "localhost". Yet mine is not there. So I had to tell the crawler where to look.
This is the code I had to add 'HTTP_HOST' => 'my.server.location'
Adding this code makes the code look like this:
$this->client = static::createClient(
array(),
array(
'HTTP_HOST' => 'my.server.location', //dependent on server
));
$this->client->followRedirects(true);
So now when I get the url $crawler = $client->request('GET', '/admin/login');
, The crawler will get the following url: http://my.server.location/admin/login
.
Hope this helps anyone!
And credits to Matt for the answer