cacheService = app('CacheService'); } public function testPutAndGet(){ $key = md5(microtime(true)); $result=$this->cacheService->getOrExecute($key,function (){ return 'yes'; }); $this->assertEquals('yes',$result); $this->assertEquals('yes',Cache::pull($key));//销毁 } // public function testNullFunction(){ // $this->expectException(\Exception::class); // $key = md5(microtime(true)); // $this->cacheService->getOrExecute($key,null); // } }