public function testReverseTransformValidProvider() { $provider = $this->getMock('Sonata\\MediaBundle\\Provider\\MediaProviderInterface'); $provider->expects($this->once())->method('transform'); $pool = new Pool('default'); $pool->addProvider('default', $provider); $media = $this->getMock('Sonata\\MediaBundle\\Model\\MediaInterface'); $media->expects($this->exactly(2))->method('getProviderName')->will($this->returnValue('default')); $transformer = new ProviderDataTransformer($pool); $transformer->reverseTransform($media); }
public function testReverseTransformWithMediaAndUploadFileInstance() { $provider = $this->getMock('Sonata\\MediaBundle\\Provider\\MediaProviderInterface'); $pool = new Pool('default'); $pool->addProvider('default', $provider); $media = $this->getMock('Sonata\\MediaBundle\\Model\\MediaInterface'); $media->expects($this->exactly(3))->method('getProviderName')->will($this->returnValue('default')); $media->expects($this->any())->method('getId')->will($this->returnValue(1)); $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue(new UploadedFile(__FILE__, 'ProviderDataTransformerTest'))); $transformer = new ProviderDataTransformer($pool, 'stdClass', array('new_on_update' => false)); $transformer->reverseTransform($media); }