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);
}