You are here

public function LazyLoadingMetadataFactoryTest::testReadMetadataFromCache in Plug 7

File

lib/Symfony/validator/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php, line 89

Class

LazyLoadingMetadataFactoryTest

Namespace

Symfony\Component\Validator\Tests\Mapping\Factory

Code

public function testReadMetadataFromCache() {
  $loader = $this
    ->getMock('Symfony\\Component\\Validator\\Mapping\\Loader\\LoaderInterface');
  $cache = $this
    ->getMock('Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface');
  $factory = new LazyLoadingMetadataFactory($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));
}