public function testGetGalleryMediaAction()
 {
     $media = $this->getMock('Sonata\\MediaBundle\\Model\\MediaInterface');
     $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)));
     $gManager = $this->getMock('Sonata\\MediaBundle\\Model\\GalleryManagerInterface');
     $gManager->expects($this->once())->method('findOneBy')->will($this->returnValue($gallery));
     $gController = new GalleryController($gManager);
     $this->assertEquals(array($media), $gController->getGalleryMediasAction(1));
 }
 public function testDeleteGalleryMediaGalleryhasmediaInvalidAction()
 {
     $media = $this->getMock('Sonata\\MediaBundle\\Model\\MediaInterface');
     $media2 = $this->getMock('Sonata\\MediaBundle\\Model\\MediaInterface');
     $media2->expects($this->any())->method('getId')->will($this->returnValue(2));
     $galleryHasMedia = $this->getMock('Sonata\\MediaBundle\\Model\\GalleryHasMediaInterface');
     $galleryHasMedia->expects($this->once())->method('getMedia')->will($this->returnValue($media2));
     $gallery = $this->getMock('Sonata\\MediaBundle\\Model\\GalleryInterface');
     $gallery->expects($this->any())->method('getGalleryHasMedias')->will($this->returnValue(new ArrayCollection(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->deleteGalleryMediaGalleryhasmediaAction(1, 1);
     $this->assertInstanceOf('FOS\\RestBundle\\View\\View', $view);
     $this->assertEquals(400, $view->getStatusCode(), 'Should return 400');
 }