I have found that the functional tests in Symfony2 always try to request pages as "http://localhost"
My environment is setup with virtual hosts so I have my application at "http://symfony.dev"
After some testing I have found that if I run:
var_dump($client->getResponse()->getContent());
I will get the page I want, but if I var_dump the $crawler I can see that rather than requesting a page like "http://symfony.dev/page" it requested "http://localhost/page"
That gives a 404 so I am unable to test forms and so on.
Is there anyway to set the base URL to get this to work? Should I instead use something different like Selenium?
I found that I can pass the domain in to the Client. I will just make a base WebTestCase
with this functionality so my tests work.
$client = static::createClient(array(), array('HTTP_HOST' => 'symfony.dev'));
$client->followRedirects(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With