setSource($srcWidth, $srcHeight) ->setResizeStrategy($strategy) ->setBaseWidthHeight($targetWidth, $targetHeight) ->setBaseAspecRatio($aspectRatio) ->setBaseDevicePixelRate($dpr) ->prepareTargetDimensions(); $this->assertEquals($expectedWidth, $img->getTargetWidth(), "Width not correct."); $this->assertEquals($expectedHeight, $img->getTargetHeight(), "Height not correct."); $img->calculateTargetWidthAndHeight(); $this->assertEquals($expectedWidth2, $img->getTargetWidth(), "Width not correct."); $this->assertEquals($expectedHeight2, $img->getTargetHeight(), "Height not correct."); } */ /** * Provider * * @return array */ public function providerFaultImages() { return array( array('xx', 100, null, 1), array( 100, 'yy', null, 1), array( 100, 100, 'zz', 1), array( 100, 100, null, -1), ); } /** * Test * * @dataProvider providerFaultImages * * @expectedException Exception * * @return void */ public function testResizeFaults($targetWidth, $targetHeight, $aspectRatio, $dpr) { $img = new CImageResizer(/*'logger'*/); $img->setBaseWidthHeight($targetWidth, $targetHeight) ->setBaseAspecRatio($aspectRatio) ->setBaseDevicePixelRate($dpr); } /** * Provider * * @return array */ public function providerResizeStrategy() { return array( array(CImageResizer::KEEP_RATIO, "KEEP_RATIO"), array(CImageResizer::CROP_TO_FIT, "CROP_TO_FIT"), array(CImageResizer::FILL_TO_FIT, "FILL_TO_FIT"), array(-1, "UNKNOWN"), ); } /** * Test * * @dataProvider providerResizeStrategy * * @return void */ public function testResizeStrategy($strategy, $str) { $img = new CImageResizer(/*'logger'*/); $img->setResizeStrategy($strategy); $res = $img->getResizeStrategyAsString(); $this->assertEquals($str, $res, "Strategy not matching."); } }