我使用的是Laravel 4.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. ***
}
答案 0 :(得分:0)
第三个参数必须是您的参数并设置空数组 尝试
$crawler = $this->action('GET', 'AppController@getList', $params);