Symfony 2 Functional Testing external URL

别等时光非礼了梦想. 提交于 2019-12-19 11:31:11

问题


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:


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.



来源:https://stackoverflow.com/questions/17657544/symfony-2-functional-testing-external-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!