带有get参数的Laravel单元测试动作
我使用的是Laravel4.2,我试图对一个带有“get”参数的操作运行一个单元测试。我努力使这项工作失败了。我如何运行一个单元测试,使用“GET”参数对控制器操作执行“GET”带有get参数的Laravel单元测试动作,laravel,laravel-4,Laravel,Laravel 4,我使用的是Laravel4.2,我试图对一个带有“get”参数的操作运行一个单元测试。我努力使这项工作失败了。我如何运行一个单元测试,使用“GET”参数对控制器操作执行“GET” public function testGetList() { // test url "http://localhost/list" $crawler = $this->action('GET', 'AppController@getList'); } public function testGet
public function testGetList()
{
// test url "http://localhost/list"
$crawler = $this->action('GET', 'AppController@getList');
}
public function testGetListWithParams()
{
// test url equivalent of "http://localhost/list?dateFrom=2015-01-01&dateTo=2015-12-31"
$params = array('dateFrom'=>'2015-01-01','dateTo'=>'2015-12-31');
$crawler = $this->action('GET', 'AppController@getList', array(), $params);
// *** this is not working, the get parameters are not being passed. ***
}
Hi第三个参数必须是您的参数,并且您设置了空数组 试一试
谢谢。由于我使用的是“$\u GET”而不是\Input::,因此我们的“我的问题”已存在。执行:$crawler=$this->action('GET','AppController@getList“,$params);与:$crawler=$this->action('GET','AppController@getList,数组(),$params);使用\Input::get()获取参数时。我使用的是$\u GET,它无论如何都不能识别任何参数。
$crawler = $this->action('GET', 'AppController@getList', $params);