/** * Test hasKey method */ public function testHasKey() { $this->setDir(); $this->getDir(); $this->directoryMock->freeze(); $this->filemanagerMock->fileExists($this->getCachedFilePath())->once()->andReturn(true); $this->filemanagerMock->freeze(); $fileCache = new FileCache(self::PATH, $this->filemanagerMock); $this->assertTrue($fileCache->hasKey(self::KEY)); $this->directoryMock->assertExpectations(); $this->filemanagerMock->assertExpectations(); }
/** * Test load method key not found exception */ public function testLoadKeyNotFound() { $this->memoryCacheMock->hasKey(self::KEY)->once()->andReturn(false); $this->memoryCacheMock->load(self::KEY)->never(); $this->memoryCacheMock->freeze(); $this->fileCacheMock->hasKey(self::KEY)->once()->andReturn(false); $this->fileCacheMock->load(self::KEY)->never(); $this->fileCacheMock->freeze(); $smartCache = new SmartCache($this->fileCacheMock, $this->memoryCacheMock); $this->setExpectedException('Hadamcik\\SmartCache\\KeyNotFoundException'); $smartCache->load(self::KEY); }