computeResize() public method

Calculate the resize coordinates
public computeResize ( ) : array
return array The resize coordinates (width, height, target_x, target_y, target_width, target_height)
Esempio n. 1
0
 /**
  * Tests resizing with an important part.
  *
  * @param array $arguments
  * @param array $expectedResult
  *
  * @dataProvider getComputeResizeDataWithImportantPart
  */
 public function testComputeResizeWithImportantPart($arguments, $expectedResult)
 {
     /** @var File|\PHPUnit_Framework_MockObject_MockObject $fileMock */
     $fileMock = $this->getMockBuilder('Contao\\File')->setMethods(['__get', 'exists'])->setConstructorArgs(['dummy.jpg'])->getMock();
     $fileMock->expects($this->any())->method('exists')->will($this->returnValue(true));
     $fileMock->expects($this->any())->method('__get')->will($this->returnCallback(function ($key) use($arguments) {
         switch ($key) {
             case 'extension':
                 return 'jpg';
             case 'path':
                 return 'dummy.jpg';
             case 'width':
             case 'viewWidth':
                 return $arguments[2];
             case 'height':
             case 'viewHeight':
                 return $arguments[3];
             default:
                 return null;
         }
     }));
     $imageObj = new Image($fileMock);
     $imageObj->setTargetWidth($arguments[0]);
     $imageObj->setTargetHeight($arguments[1]);
     $imageObj->setResizeMode($arguments[4]);
     $imageObj->setZoomLevel($arguments[5]);
     $imageObj->setImportantPart($arguments[6]);
     $this->assertEquals($expectedResult, $imageObj->computeResize());
 }