Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function warmUp($cacheDir)
 {
     if (!class_exists(CacheClassMetadataFactory::class) || !method_exists(XmlFileLoader::class, 'getMappedClasses') || !method_exists(YamlFileLoader::class, 'getMappedClasses')) {
         return;
     }
     $adapter = new PhpArrayAdapter($this->phpArrayFile, $this->fallbackPool);
     $arrayPool = new ArrayAdapter(0, false);
     $metadataFactory = new CacheClassMetadataFactory(new ClassMetadataFactory(new LoaderChain($this->loaders)), $arrayPool);
     foreach ($this->extractSupportedLoaders($this->loaders) as $loader) {
         foreach ($loader->getMappedClasses() as $mappedClass) {
             $metadataFactory->getMetadataFor($mappedClass);
         }
     }
     $values = $arrayPool->getValues();
     $adapter->warmUp($values);
     foreach ($values as $k => $v) {
         $item = $this->fallbackPool->getItem($k);
         $this->fallbackPool->saveDeferred($item->set($v));
     }
     $this->fallbackPool->commit();
 }
 /**
  * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
  */
 public function testInvalidClassThrowsException()
 {
     $decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock();
     $factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
     $factory->getMetadataFor('Not\\Exist');
 }
 /**
  * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
  */
 public function testInvalidClassThrowsException()
 {
     $decorated = $this->getMock('Symfony\\Component\\Serializer\\Mapping\\Factory\\ClassMetadataFactoryInterface');
     $factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
     $factory->getMetadataFor('Not\\Exist');
 }