mirror of
https://github.com/mosbth/cimage.git
synced 2025-07-23 17:51:34 +02:00
resize-strategies together with no upscale
This commit is contained in:
@@ -21,17 +21,17 @@ class CImageResizerStrategyKeepAspectRatioTest extends \PHPUnit_Framework_TestCa
|
||||
array(100, 100, 200, 200, 200, 200, 0, 0, 100, 100),
|
||||
|
||||
// Landscape
|
||||
array(100, 200, null, null, 100, 200, 0, 0, 100, 200),
|
||||
array(100, 200, null, 100, 50, 100, 0, 0, 100, 200),
|
||||
array(100, 200, 50, null, 50, 100, 0, 0, 100, 200),
|
||||
array(100, 200, 50, 100, 50, 100, 0, 0, 100, 200),
|
||||
|
||||
// Portrait
|
||||
array(200, 100, null, null, 200, 100, 0, 0, 200, 100),
|
||||
array(200, 100, null, 200, 400, 200, 0, 0, 200, 100),
|
||||
array(200, 100, 400, null, 400, 200, 0, 0, 200, 100),
|
||||
array(200, 100, 400, 200, 400, 200, 0, 0, 200, 100),
|
||||
|
||||
// Portrait
|
||||
array(100, 200, null, null, 100, 200, 0, 0, 100, 200),
|
||||
array(100, 200, null, 100, 50, 100, 0, 0, 100, 200),
|
||||
array(100, 200, 50, null, 50, 100, 0, 0, 100, 200),
|
||||
array(100, 200, 50, 100, 50, 100, 0, 0, 100, 200),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
@@ -61,4 +61,66 @@ class CImageResizerStrategyKeepAspectRatioTest extends \PHPUnit_Framework_TestCa
|
||||
$this->assertEquals($cw, $img->getCropWidth(), "CropWidth not correct.");
|
||||
$this->assertEquals($ch, $img->getCropHeight(), "CropHeight not correct.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Provider
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function providerImages2()
|
||||
{
|
||||
return array(
|
||||
|
||||
// Square
|
||||
array(100, 100, 100, 100, 100, 100, 0, 0, 100, 100),
|
||||
array(100, 100, null, 200, 100, 100, 0, 0, 100, 100),
|
||||
array(100, 100, 200, null, 100, 100, 0, 0, 100, 100),
|
||||
array(100, 100, 200, 100, 100, 100, 0, 0, 100, 100),
|
||||
array(100, 100, 100, 200, 100, 100, 0, 0, 100, 100),
|
||||
array(100, 100, 200, 200, 100, 100, 0, 0, 100, 100),
|
||||
|
||||
// Landscape
|
||||
//array(200, 100, null, null, 200, 100, 0, 0, 200, 100),
|
||||
//array(200, 100, null, 200, 400, 200, 0, 0, 200, 100),
|
||||
//array(200, 100, 400, null, 400, 200, 0, 0, 200, 100),
|
||||
//array(200, 100, 400, 200, 400, 200, 0, 0, 200, 100),
|
||||
|
||||
// Portrait
|
||||
//array(100, 200, null, null, 100, 200, 0, 0, 100, 200),
|
||||
//array(100, 200, null, 100, 50, 100, 0, 0, 100, 200),
|
||||
//array(100, 200, 50, null, 50, 100, 0, 0, 100, 200),
|
||||
//array(100, 200, 50, 100, 50, 100, 0, 0, 100, 200),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test
|
||||
*
|
||||
* @dataProvider providerImages2
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testResize2($sw, $sh, $tw, $th, $twa, $tha, $cx, $cy, $cw, $ch)
|
||||
{
|
||||
$img = new CImageResizer(/*'logger'/**/);
|
||||
|
||||
$img->setSource($sw, $sh)
|
||||
->setBaseWidthHeight($tw, $th)
|
||||
->setResizeStrategy(CImageResizer::KEEP_RATIO)
|
||||
->allowUpscale(false)
|
||||
->calculateTargetWidthAndHeight();
|
||||
|
||||
$this->assertEquals($twa, $img->getTargetWidth(), "Target width not correct.");
|
||||
$this->assertEquals($tha, $img->getTargetHeight(), "Target height not correct.");
|
||||
|
||||
$this->assertEquals($cx, $img->getCropX(), "CropX not correct.");
|
||||
$this->assertEquals($cy, $img->getCropY(), "CropY not correct.");
|
||||
$this->assertEquals($cw, $img->getCropWidth(), "CropWidth not correct.");
|
||||
$this->assertEquals($ch, $img->getCropHeight(), "CropHeight not correct.");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user