public function testforgetCodeFromCache_putCodeToCache_getCodeFromCache_setCacheMinutes() { $this->vcode->setStore($st = new Store()); $this->vcode->setCacheMinutes(13); $this->vcode->putCodeToCache($mobile = 'mo-hello', $code = 'c-code', $bag = 'bag-my'); $this->assertNotEmpty($st); $this->assertSame($code, $this->vcode->getCodeFromCache($mobile, $bag)); $this->assertSame(13, $st->store[$this->vcode->getCacheKey($mobile, $bag)]['min']); $this->vcode->forgetCodeFromCache($mobile, $bag); $this->assertEmpty($st->store); }
/** * 注册短信验证码的生送与判断对象 */ protected function regSmsVCodeService() { $this->app->singleton('windq.sms_vcode_service', function () { $vcode = new VCode(); $vcode->setSender($this->makeSmsSender()); $vcode->setStore($this->app->make('cache.store')); return $vcode; }); }