Symfony 2功能测试外部URL [英] Symfony 2 Functional Testing external URL

查看:98
本文介绍了Symfony 2功能测试外部URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论做什么,我总是得到

Whatever I do, I always get a

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException:否 找到[...]"

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

中的

,当我尝试使用$crawler = $client->request('GET', 'http://anotherdomain.com');请求外部URL时.

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

之所以要这样做,是因为我正在使用另一个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.

我也试图

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

但是它一直在用Symfony 2渲染它.

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

推荐答案

这是不可能的,因为$client实际上不会发送任何http请求(您可能会注意到,当您尝试使用www服务器运行功能性"测试时,残疾人-他们仍然应该工作).取而代之的是,它模拟http请求并运行正常的Symfony调度.

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.

这篇关于Symfony 2功能测试外部URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆