1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-07-23 09:41:39 +02:00

calculate target dimensions

This commit is contained in:
Mikael Roos
2015-10-27 00:21:36 +01:00
parent f9a4205579
commit 9bf94e9cf6
3 changed files with 291 additions and 2 deletions

View File

@@ -0,0 +1,43 @@
<?php
/**
* A testclass
*
*/
class CImageResizerTest extends \PHPUnit_Framework_TestCase
{
/**
* Provider
*
* @return array
*/
public function providerImages()
{
return array(
// Same as source, does not set target
array(100, 100, null, null, null, 1, null, null),
array(100, 150, null, null, null, 1, null, null),
array(150, 100, null, null, null, 1, null, null),
);
}
/**
* Test
*
* @dataProvider providerImages
*
* @return void
*/
public function testResize1($srcWidth, $srcHeight, $targetWidth, $targetHeigth, $aspectRatio, $dpr, $expectedWidth, $expectedHeight)
{
$img = new CImageResizer();
$img->setSource($srcWidth, $srcHeight)
->setBaseForCalculateTarget($targetWidth, $targetHeigth, $aspectRatio, $dpr)
->prepareTargetDimensions();
$this->assertEquals($expectedWidth, $img->width(), "Width not correct.");
$this->assertEquals($expectedHeight, $img->height(), "Heigth not correct.");
}
}