Symfony 2 Functional Testing external URL

2019-02-20 16:04发布

Whatever I do, I always get a

Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for [...]"

in $crawler->text(), when I try to request an external URL with $crawler = $client->request('GET', 'http://anotherdomain.com');.

I want to do that because I'm using another virtualHost to render some pages with Symfony 1.2 and some others with Symfony 2.3.

I also tried to

$client = static::createClient(array(), array('HTTP_HOST' => 'anotherdomain.com'));
$client->followRedirects(true);

But it's always trying to render it whithin Symfony 2.

1条回答
放我归山
2楼-- · 2019-02-20 16:13

It's not possible, because $client actually doesn't send any http request (you may notice that when you try run your "functional" test with www server disabled - they still should work). Instead of that it simulates http request and run normal Symfony's dispatching.

查看更多
登录 后发表回答