Ejemplo n.º 1
0
 public function testPostGalleryMediaGalleryhasmediaInvalidAction()
 {
     $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));
     $formFactory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface');
     $galleryController = new GalleryController($galleryManager, $mediaManager, $formFactory, 'Sonata\\MediaBundle\\Tests\\Controller\\Api\\GalleryTest');
     $view = $galleryController->postGalleryMediaGalleryhasmediaAction(1, 1, new Request());
     $this->assertInstanceOf('FOS\\RestBundle\\View\\View', $view);
     $this->assertEquals(400, $view->getStatusCode(), 'Should return 400');
 }