public function getProvider() { $resizer = $this->getMock('Sonata\MediaBundle\Media\ResizerInterface', array('resize')); $resizer->expects($this->any()) ->method('resize') ->will($this->returnValue(true)); $adapter = $this->getMock('Gaufrette\Filesystem\Adapter'); $file = $this->getMock('Gaufrette\Filesystem\File', array(), array($adapter)); $filesystem = $this->getMock('Gaufrette\Filesystem\Filesystem', array('get'), array($adapter)); $filesystem->expects($this->any()) ->method('get') ->will($this->returnValue($file)); $cdn = new \Sonata\MediaBundle\CDN\Server('/updoads/media'); $generator = new \Sonata\MediaBundle\Generator\DefaultGenerator(); $provider = new \Sonata\MediaBundle\Provider\YouTubeProvider('file', $filesystem, $cdn, $generator); $provider->setResizer($resizer); return $provider; }
/** * Gets the 'sonata.media.provider.youtube' service. * * This service is shared. * This method always returns the same instance of the service. * * @return Sonata\MediaBundle\Provider\YouTubeProvider A Sonata\MediaBundle\Provider\YouTubeProvider instance. */ protected function getSonata_Media_Provider_YoutubeService() { $this->services['sonata.media.provider.youtube'] = $instance = new \Sonata\MediaBundle\Provider\YouTubeProvider('sonata.media.provider.youtube', $this->get('sonata.media.filesystem.local'), $this->get('sonata.media.cdn.server'), $this->get('sonata.media.generator.default'), $this->get('sonata.media.thumbnail.format'), $this->get('sonata.media.buzz.browser'), $this->get('sonata.media.metadata.proxy'), false); $instance->setTemplates(array('helper_thumbnail' => 'SonataMediaBundle:Provider:thumbnail.html.twig', 'helper_view' => 'SonataMediaBundle:Provider:view_youtube.html.twig')); $instance->addFormat('default_small', array('width' => 100, 'quality' => 70, 'height' => false, 'format' => 'jpg', 'constraint' => true)); $instance->addFormat('default_big', array('width' => 500, 'quality' => 70, 'height' => false, 'format' => 'jpg', 'constraint' => true)); $instance->setResizer($this->get('sonata.media.resizer.simple')); $instance->addFormat('admin', array('quality' => 80, 'width' => 100, 'format' => 'jpg', 'height' => false, 'constraint' => true)); return $instance; }