protected function setUp()
 {
     $this->namingStrategy = $this->getMock('Sp\\FixtureDumper\\Generator\\NamingStrategyInterface');
     $this->manager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $this->metadata = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
     $this->repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
     $this->generator = $this->loadGenerator();
     $this->handlerRegistry = new HandlerRegistry();
     $this->handlerRegistry->addSubscribingHandler(new DateHandler());
     $this->generator->setNavigator(new DefaultNavigator($this->handlerRegistry, $this->getFormat()));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $folder = $input->getArgument('folder');
     if (strpos($folder, '.') !== false) {
         throw new \RuntimeException('Dots are not allowed.');
     }
     $folder = $this->container->getParameter('directories.project_root') . DIRECTORY_SEPARATOR . $folder;
     if (!is_dir($folder)) {
         throw new \RuntimeException(sprintf('Invalid directory [%s].'), $folder);
     }
     $registry = new HandlerRegistry();
     $registry->addSubscribingHandler(new DateHandler());
     $registry->addSubscribingHandler(new SupraPathHandler());
     $dumper = new ORMDumper($this->container->getDoctrine()->getManager(), $registry, new Map(array('yml' => new SupraYamlFixtureGenerator())));
     $dumper->setDumpMultipleFiles(false);
     $dumper->dump($folder, 'yml');
     //dump files
     $entityManager = $this->container->getDoctrine()->getManager();
     $fileStorage = $this->container['cms.file_storage'];
     /* @var $fileStorage FileStorage */
     foreach ($entityManager->getRepository(File::CN())->findAll() as $file) {
         /* @var $file File */
         if ($fileStorage->fileExists($file)) {
             copy($fileStorage->getFilesystemPath($file), $this->getFileTemporaryName($file, $folder));
         }
         if ($file instanceof Image) {
             foreach ($file->getImageSizeCollection() as $imageSize) {
                 /* @var $imageSize ImageSize */
                 $imageSizePath = $fileStorage->getImagePath($file, $imageSize->getName());
                 if (is_file($imageSizePath)) {
                     copy($imageSizePath, $this->getImageSizeTemporaryName($imageSize, $folder));
                 }
             }
         }
     }
 }