更新Laravel 6.0后缓存模拟异常

时间:2019-09-10 15:14:48

标签: laravel-6

我使用Cache模拟进行单元测试。在将laravel更新到6.0之前,效果很好

更新后,我进行了测试并获得了异常

  

Mockery \ Exception \ BadMethodCallException:已收到   Mockery_2_Illuminate_Cache_CacheManager :: driver(),但没有期望   被指定

    Cache::shouldReceive('get')
        ->once()
        ->with('table_3_'.config('constants.league.premier').'_'.config('constants.sex.female'))
        ->andReturn(json_encode([
            [
                'id' => $team1->id,
                'place' => 1
            ],
            [
                'id' => $team2->id,
                'place' => 8
            ],
            [
                'id' => $team3->id,
                'place' => 11
            ],
        ]));

    $this->artisan('passport:transfer');

1 个答案:

答案 0 :(得分:0)

我在这里找到了答案-Laravel Feature Testing. Cache mocking not working! CacheManager::driver(), but no expectations were specified

但是我不明白为什么在更新测试之前还可以