Laravel 5 在laravel 5.8 phpunit测试中,控制器在雄辩的查询中返回null

Laravel 5 在laravel 5.8 phpunit测试中,控制器在雄辩的查询中返回null,laravel-5,eloquent,phpunit,mockery,Laravel 5,Eloquent,Phpunit,Mockery,我正在尝试为模型ProjectRating创建一个模拟,其中我希望根据模型的查询返回一个特定值。使用select和first时,我接收到设置的结果值,但当查询中有where时,我将得到null 我在控制器中的查询如下所示 $projectRating = ProjectRating::select('rating') ->where('project_id', $projectId) ->where('country_i

我正在尝试为模型
ProjectRating
创建一个模拟,其中我希望根据模型的查询返回一个特定值。使用
select
first
时,我接收到设置的结果值,但当查询中有
where
时,我将得到null

我在控制器中的查询如下所示

$projectRating = ProjectRating::select('rating')
                ->where('project_id', $projectId)
                ->where('country_id', $countryId)
                ->where('language_id', $languageId)
                ->first() ;
$fakeProjectRating = \Mockery::mock(ProjectRating::class);

$fakeProjectRating->shouldReceive('select->where->where->where->first')->andReturn(['rating'=>'c']);

app()->instance(ProjectRating::class, $fakeProjectRating);

我的测试代码如下所示

$projectRating = ProjectRating::select('rating')
                ->where('project_id', $projectId)
                ->where('country_id', $countryId)
                ->where('language_id', $languageId)
                ->first() ;
$fakeProjectRating = \Mockery::mock(ProjectRating::class);

$fakeProjectRating->shouldReceive('select->where->where->where->first')->andReturn(['rating'=>'c']);

app()->instance(ProjectRating::class, $fakeProjectRating);

提前谢谢