Angejia\Pea\ModelTest::testMissAwfulGet PHP Метод

testMissAwfulGet() публичный метод

复杂查询未命中缓存
public testMissAwfulGet ( )
    public function testMissAwfulGet()
    {
        // 模拟数据库返回结果
        $this->conn->shouldReceive('select')->with('select * from "user" where "status" = ? order by "id" desc', [1], true)->andReturn([(object) ['id' => 1, 'name' => '海涛']]);
        // 模拟未命中缓存
        $this->cache->shouldReceive('get')->with(['a52d401e05fd1cc438bd070bc4c1c14f'])->andReturn([]);
        // 模拟缓存查询结果
        $this->cache->shouldReceive('set')->with(['a52d401e05fd1cc438bd070bc4c1c14f' => [(object) ['id' => 1, 'name' => '海涛']]]);
        $dispatcher = M::Mock(Dispatcher::class);
        $dispatcher->shouldReceive('fire')->with('angejia.pea.get', ['table' => 'user', 'db' => 'angejia']);
        $dispatcher->shouldReceive('fire')->with('angejia.pea.miss.awful', ['table' => 'user', 'db' => 'angejia']);
        $this->app->instance(Dispatcher::class, $dispatcher);
        $uers = User::where('status', 1)->orderBy('id', 'desc')->get();
    }