我在我的代码中有这样一行:
ModelName::create($data);
Run Code Online (Sandbox Code Playgroud)
其中ModelName只是一个Eloquent模型.有没有办法在单元测试中模拟这个调用?我尝试过:
$client_mock = \Mockery::mock('Eloquent','App\Models\ModelName');
$client_mock->shouldReceive('create')
->with($data)->andReturns($returnValue);
Run Code Online (Sandbox Code Playgroud)
但它不起作用.