Exemplo n.º 1
0
 /**
  * Test save method
  */
 public function testSave()
 {
     $this->setDir();
     $this->getDir();
     $this->directoryMock->freeze();
     $this->filemanagerMock->createFile($this->getCachedFilePath(), self::SERIALIZED_VALUE)->andReturn($this->regularFileMock);
     $this->filemanagerMock->freeze();
     $fileCache = new FileCache(self::PATH, $this->filemanagerMock);
     $this->assertInstanceOf('Hadamcik\\SmartCache\\Utils\\Filemanager\\RegularFile', $fileCache->save(self::KEY, self::VALUE));
     $this->directoryMock->assertExpectations();
     $this->filemanagerMock->assertExpectations();
 }
 /**
  * Test load method correctly
  */
 public function testLoadObject()
 {
     $fileCache = new FileCache($this->getTempPath(), $this->filemanager);
     $object = new TestClass('value');
     $object->publicParam = 'public';
     $fileCache->save(self::KEY, $object);
     $this->assertEquals($object, $fileCache->load(self::KEY));
     $object->setPrivateParam('new value');
     $this->assertNotEquals($object, $fileCache->load(self::KEY));
 }
 /**
  * Test load method correctly by file cache
  */
 public function testLoadFileCache()
 {
     $this->fileCache->save(self::KEY, self::VALUE);
     $this->assertSame(self::VALUE, $this->smartCache->load(self::KEY));
 }