Exemple #1
0
 /**
  * @covers SwfTools\Binary\Swfextract::extract
  */
 public function testExtract()
 {
     $file = __DIR__ . '/../../../files/flashfile.swf';
     $flash = new \SwfTools\Processor\FlashFile(DriverContainer::create());
     $embeddeds = $flash->listEmbeddedObjects($file);
     $embedded = null;
     foreach ($embeddeds as $e) {
         if ($e->getType() === \SwfTools\EmbeddedObject::TYPE_JPEG) {
             $embedded = $e;
             break;
         }
     }
     $dest_file = __DIR__ . '/../../../files/tmp.jpg';
     $this->object->extract($file, $embedded, $dest_file);
     $sizes = getimagesize($dest_file);
     $this->assertTrue(file_exists($dest_file));
     unlink($dest_file);
     try {
         $this->object->extract($file, $embedded, '');
         $this->fail('Should fail on invalid destination');
     } catch (\SwfTools\Exception\InvalidArgumentException $exception) {
     }
     $this->assertEquals(1440, $sizes[0]);
     $this->assertEquals(420, $sizes[1]);
     $fakeFile = __DIR__ . '/../../../files/nofile';
     try {
         $this->object->extract($fakeFile, $embedded, $dest_file);
         $this->fail('Swfrender should file on an unexistent file');
     } catch (\SwfTools\Exception\RuntimeException $exception) {
     }
 }
 public static function create($configuration = array(), LoggerInterface $logger = null)
 {
     $container = new static();
     $container['configuration'] = $configuration;
     $container['logger'] = $logger;
     $container['pdf2swf'] = $container->share(function ($container) {
         return Pdf2swf::create($container['configuration'], $container['logger']);
     });
     $container['swfrender'] = $container->share(function ($container) {
         return Swfrender::create($container['configuration'], $container['logger']);
     });
     $container['swfextract'] = $container->share(function ($container) {
         return Swfextract::create($container['configuration'], $container['logger']);
     });
     return $container;
 }