我想在laravel 4.1中创建单元测试。我是laravel和PHP的新手。所以我想知道如何拨打下面提到的路线。
这是我使用身份验证过滤器的路线。
Route.php
Route::get('um',array('before' => 'auth.required'),'UMController@showAll');
该路线的控制器是
UMController.php
public function showAll(){
$um=Um::all();
return $um;
}
调用路线的我的单位测试功能是。
UMTest.php
public function testPush()
{
$this->be(User::find(7));
$this->call('GET', 'um');
}
但是我得到了错误。 ErrorException:call_user_func_array()期望参数1是有效的回调,没有给定的数组或字符串
答案 0 :(得分:0)
我认为你的路线是问题
Route::get('um',array('before' => 'auth.required'),'UMController@showAll');
试试这个
Route::get('um', array('before' => 'auth.required', 'uses' => 'UMController@showAll'));
答案 1 :(得分:0)
我尝试很多次这个例子对我有用
Route::get(‘start’, array(‘before’ => ‘auth.required’ => ‘data@yourdomain’));