在Symfony2的功能测试Ajax / XMLHtt prequest页功能、测试、prequest、XMLHtt

2023-09-10 16:07:09 作者:collapse(崩溃)

是否可以模拟/做出XMLHtt prequest请求(AJAX)的Symfony2的测试?

Is it possible to simulate/make an XMLHttpRequest request (ajax) in symfony2 tests?

推荐答案

搜索与有问题的答案后,正确的语法如下:

After search with "Problematic" answer, the correct syntax is:

$crawler = $client->request('GET', '/foo/', array(), array(), array(
    'HTTP_X-Requested-With' => 'XMLHttpRequest',
));