时间:2021-07-01 10:21:17 帮助过:3人阅读
BadMethodCallException: Method Mockery_0_Illuminate_Auth_AuthManager::user() does not exist on this mock object
报错的地方部分代码如下:
function writeLog($record = ''){
$data = array(
'uid' => Auth::user()->id,//调用这一行的时候报错
'ip' => $this->request->ip(),
'created_at' => Carbon::now()
);
OperateLog::create($data);
}
请问这个应该如何处理?
用laravel做单元测试的时候报错如下:
BadMethodCallException: Method Mockery_0_Illuminate_Auth_AuthManager::user() does not exist on this mock object
报错的地方部分代码如下:
function writeLog($record = ''){
$data = array(
'uid' => Auth::user()->id,//调用这一行的时候报错
'ip' => $this->request->ip(),
'created_at' => Carbon::now()
);
OperateLog::create($data);
}
请问这个应该如何处理?