Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有get参数的Laravel单元测试动作_Laravel_Laravel 4 - Fatal编程技术网

带有get参数的Laravel单元测试动作

带有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

我使用的是Laravel4.2,我试图对一个带有“get”参数的操作运行一个单元测试。我努力使这项工作失败了。我如何运行一个单元测试,使用“GET”参数对控制器操作执行“GET”

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);