public function testReadReturnsCache() { $file = $this->getFile(); $signature = new Signature(PHP_VERSION, '2.0', true, array('foo', 'bar')); $cache = new Cache($signature); file_put_contents($file, $cache->toJson()); $handler = new FileHandler($file); $cached = $handler->read(); $this->assertInstanceOf('PhpCsFixer\\Cache\\CacheInterface', $cached); $this->assertTrue($cached->getSignature()->equals($signature)); }
public function testCanConvertToAndFromJson() { $signature = new Signature(PHP_VERSION, '2.0', true, array('foo', 'bar')); $cache = new Cache($signature); $file = 'test.php'; $hash = crc32('hello'); $cache->set($file, $hash); /* @var Cache $cached */ $cached = Cache::fromJson($cache->toJson()); $this->assertTrue($cached->getSignature()->equals($signature)); $this->assertTrue($cached->has($file)); $this->assertSame($hash, $cached->get($file)); }