Cache is supported only for phar version and version installed via composer.
File will be processed by PHP CS Fixer only if any of the following conditions is fulfilled:
- cache is corrupt
- fixer version changed
- rules changed
- file is new
- file changed
public function testSetFileUsesRelativePathToFile() { $cacheFile = $this->getFile(); $file = '/foo/bar/baz/src/hello.php'; $relativePathToFile = 'src/hello.php'; $fileContent = '<?php echo "Hello!"'; $directory = $this->getDirectoryMock(); $directory->expects($this->once())->method('getRelativePathTo')->with($this->identicalTo($file))->willReturn($relativePathToFile); $cachedSignature = $this->getSignatureMock(); $signature = $this->getSignatureMock(); $signature->expects($this->once())->method('equals')->with($this->identicalTo($cachedSignature))->willReturn(true); $cache = $this->getCacheMock(); $cache->expects($this->once())->method('getSignature')->willReturn($cachedSignature); $cache->expects($this->once())->method('set')->with($this->identicalTo($relativePathToFile), $this->identicalTo(crc32($fileContent))); $handler = $this->getFileHandlerMock(); $handler->expects($this->never())->method('getFile')->willReturn($cacheFile); $handler->expects($this->once())->method('read')->willReturn($cache); $handler->expects($this->once())->method('write')->with($this->identicalTo($cache)); $manager = new FileCacheManager($handler, $signature, false, $directory); $manager->setFile($file, $fileContent); }