Contao\CoreBundle\Test\Contao\ImageTest::testComputeResizeWithoutImportantPart PHP Method

testComputeResizeWithoutImportantPart() public method

Tests resizing without an important part.
public testComputeResizeWithoutImportantPart ( array $arguments, array $expectedResult )
$arguments array
$expectedResult array
    public function testComputeResizeWithoutImportantPart($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 'viewWidth':
                    return $arguments[2];
                case 'viewHeight':
                    return $arguments[3];
                default:
                    return null;
            }
        }));
        $imageObj = new Image($fileMock);
        $imageObj->setTargetWidth($arguments[0]);
        $imageObj->setTargetHeight($arguments[1]);
        $imageObj->setResizeMode($arguments[4]);
        $this->assertEquals($expectedResult, $imageObj->computeResize());
        $imageObj->setZoomLevel(50);
        $this->assertEquals($expectedResult, $imageObj->computeResize(), 'Zoom 50 should return the same results if no important part is specified');
        $imageObj->setZoomLevel(100);
        $this->assertEquals($expectedResult, $imageObj->computeResize(), 'Zoom 100 should return the same results if no important part is specified');
    }