public function ClassMetadataFactoryTest::testReadMetadataFromCache

File

drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php, line 90

Class

ClassMetadataFactoryTest

Namespace

Symfony\Component\Validator\Tests\Mapping

Code

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