Example #1
0
 /**
  * Check crop and resize chaining
  *
  * @test
  * @group rendering
  * @group small
  * @group dev
  *
  */
 public function test_crop_resize()
 {
     $mediaId = 'MEDIA-a4464129-a64e-4af9-bb07-b94322fb36c8-MEDIA';
     $mediaUrl = 'URL/' . $mediaId;
     $left = 1;
     $top = 2;
     $newWidth = 320;
     $newHeight = 240;
     $operations = array(array('crop', $top, $left, 640, 480), array('resize', $newWidth, $newHeight, MediaImage::RESIZE_STRETCH));
     // Create MediaInfoStorage Mock
     $mediaInfoStorage = $this->getMock('\\Render\\InfoStorage\\MediaInfoStorage\\IMediaInfoStorage');
     $mediaInfoStorage->expects($this->once())->method('getImageUrl')->with($mediaId, $operations)->will($this->returnValue($mediaUrl));
     // Create MediaContext Mock
     $mediaContext = $this->createMediaContextMock();
     $mediaContext->expects($this->atLeastOnce())->method('getMediaInfoStorage')->will($this->returnValue($mediaInfoStorage));
     // Create MediaItem Mock
     $mediaItem = $this->getMockBuilder('\\Render\\APIs\\APIv1\\MediaItem')->disableOriginalConstructor()->getMock();
     $mediaItem->expects($this->once())->method('getId')->will($this->returnValue($mediaId));
     // ACT
     $mediaImage = new MediaImage($mediaContext, $mediaItem);
     $mediaImage->crop($top, $left, 640, 480);
     $mediaImage->resizeStretch($newWidth, $newHeight);
     // ASSERT
     $this->assertEquals($newWidth, $mediaImage->getWidth());
     $this->assertEquals($newHeight, $mediaImage->getHeight());
     $this->assertEquals($mediaUrl, $mediaImage->getUrl());
 }