Symfony 2功能测试外部URL [英] Symfony 2 Functional Testing external URL
问题描述
无论做什么,我总是得到
Whatever I do, I always get a
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException:否 找到[...]"
Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for [...]"
,当我尝试使用 in 之所以要这样做,是因为我正在使用另一个virtualHost来使用Symfony 1.2渲染某些页面,而使用Symfony 2.3渲染其他页面. 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. 我也试图 但是它一直在用Symfony 2渲染它. But it's always trying to render it whithin Symfony 2. 这是不可能的,因为 It's not possible, because 这篇关于Symfony 2功能测试外部URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!$crawler = $client->request('GET', 'http://anotherdomain.com');
请求外部URL时.$crawler->text()
, when I try to request an external URL with $crawler = $client->request('GET', 'http://anotherdomain.com');
.$client = static::createClient(array(), array('HTTP_HOST' => 'anotherdomain.com'));
$client->followRedirects(true);
推荐答案
$client
实际上不会发送任何http请求(您可能会注意到,当您尝试使用www服务器运行功能性"测试时,残疾人-他们仍然应该工作).取而代之的是,它模拟http请求并运行正常的Symfony调度.$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.