Ejemplo n.º 1
0
 public function testPutGalleryMediaGalleryhasmediaInvalidAction()
 {
     $media = $this->getMock('Sonata\\MediaBundle\\Model\\MediaInterface');
     $media->expects($this->any())->method('getId')->will($this->returnValue(1));
     $galleryHasMedia = $this->getMock('Sonata\\MediaBundle\\Model\\GalleryHasMediaInterface');
     $galleryHasMedia->expects($this->once())->method('getMedia')->will($this->returnValue($media));
     $gallery = $this->getMock('Sonata\\MediaBundle\\Model\\GalleryInterface');
     $gallery->expects($this->once())->method('getGalleryHasMedias')->will($this->returnValue(array($galleryHasMedia)));
     $galleryManager = $this->getMock('Sonata\\MediaBundle\\Model\\GalleryManagerInterface');
     $galleryManager->expects($this->once())->method('findOneBy')->will($this->returnValue($gallery));
     $mediaManager = $this->getMock('Sonata\\MediaBundle\\Model\\MediaManagerInterface');
     $mediaManager->expects($this->once())->method('findOneBy')->will($this->returnValue($media));
     $form = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
     $form->expects($this->once())->method('bind');
     $form->expects($this->once())->method('isValid')->will($this->returnValue(false));
     $formFactory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface');
     $formFactory->expects($this->once())->method('createNamed')->will($this->returnValue($form));
     $galleryController = new GalleryController($galleryManager, $mediaManager, $formFactory, 'Sonata\\MediaBundle\\Tests\\Controller\\Api\\GalleryTest');
     $view = $galleryController->putGalleryMediaGalleryhasmediaAction(1, 1, new Request());
     $this->assertInstanceOf('Symfony\\Component\\Form\\FormInterface', $view);
 }