public function testReadMetadataFromCache() {
$loader = $this
->getMock('Symfony\\Component\\Validator\\Mapping\\Loader\\LoaderInterface');
$cache = $this
->getMock('Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface');
$factory = new ClassMetadataFactory($loader, $cache);
$tester = $this;
$metadata = new ClassMetadata(self::PARENTCLASS);
$metadata
->addConstraint(new ConstraintA());
$loader
->expects($this
->never())
->method('loadClassMetadata');
$cache
->expects($this
->never())
->method('has');
$cache
->expects($this
->once())
->method('read')
->will($this
->returnValue($metadata));
$this
->assertEquals($metadata, $factory
->getMetadataFor(self::PARENTCLASS));
}