我想在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');
}
但是我得到了错误。错误:call_user_func_array()期望参数1是一个有效的回调,没有给定数组或字符串
我想你的路线有问题
Route::get('um',array('before' => 'auth.required'),'UMController@showAll');
试试这个
Route::get('um', array('before' => 'auth.required', 'uses' => 'UMController@showAll'));
参考
我试了很多次这个例子,它对我很有用
Route::get(‘start’, array(‘before’ => ‘auth.required’ => ‘data@yourdomain’));