1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
public function testfindBestSizeForRatioReturnValidValueForEasyInput()
{
$img = new Img_GD();
//1
$iW = 400; $iH = 300; //Input image size
$rW = 4; $rH = 3; //ratio
$eW = 400; $eH = 300; //Expected
$this->assertEquals(array($eW, $eH), $img->findBestSizeForRatio($iW, $iH, $rW, $rH), "Img: {$iW} x {$iH} Ratio: {$rW} x {$rH}");
//2
$iW = 400; $iH = 3000; //Input image size
$rW = 4; $rH = 3; //ratio
$eW = 400; $eH = 300; //Expected
$this->assertEquals(array($eW, $eH), $img->findBestSizeForRatio($iW, $iH, $rW, $rH), "Img: {$iW} x {$iH} Ratio: {$rW} x {$rH}");
//3
$iW = 4000; $iH = 300; //Input image size
$rW = 4; $rH = 3; //ratio.
$eW = 400; $eH = 300; //Expected
$this->assertEquals(array($eW, $eH), $img->findBestSizeForRatio($iW, $iH, $rW, $rH), "Img: {$iW} x {$iH} Ratio: {$rW} x {$rH}");
//4
$iW = 400; $iH = 3000; //Input image size
$rW = 3; $rH = 4; //ratio
$eW = 399; $eH = 532; //Expected
$this->assertEquals(array($eW, $eH), $img->findBestSizeForRatio($iW, $iH, $rW, $rH), "Img: {$iW} x {$iH} Ratio: {$rW} x {$rH}");
//5
$iW = 4000; $iH = 300; //Input image size
$rW = 3; $rH = 4; //ratio.
$eW = 225; $eH = 300; //Expected
$this->assertEquals(array($eW, $eH), $img->findBestSizeForRatio($iW, $iH, $rW, $rH), "Img: {$iW} x {$iH} Ratio: {$rW} x {$rH}");
//6
$iW = 4000; $iH = 300; //Input image size
$rW = 3; $rH = 4; //ratio.
$eW = 225; $eH = 300; //Expected
$this->assertEquals(array($eW, $eH), $img->findBestSizeForRatio($iW, $iH, $rW, $rH), "Img: {$iW} x {$iH} Ratio: {$rW} x {$rH}");
}
public function testfindBestSizeForRatioReturnValidValueForNonExactInput()
{
$img = new Img_GD();
//7
$iW = 403; $iH = 302; //Input image size
$rW = 4; $rH = 3; //ratio
$eW = 400; $eH = 300; //Expected
$this->assertEquals(array($eW, $eH), $img->findBestSizeForRatio($iW, $iH, $rW, $rH), "Img: {$iW} x {$iH} Ratio: {$rW} x {$rH}");
//8
$iW = 403; $iH = 3000; //Input image size
$rW = 4; $rH = 3; //ratio
$eW = 400; $eH = 300; //Expected
$this->assertEquals(array($eW, $eH), $img->findBestSizeForRatio($iW, $iH, $rW, $rH), "Img: {$iW} x {$iH} Ratio: {$rW} x {$rH}");
//9
$iW = 4000; $iH = 302; //Input image size
$rW = 4; $rH = 3; //ratio.
$eW = 400; $eH = 300; //Expected
$this->assertEquals(array($eW, $eH), $img->findBestSizeForRatio($iW, $iH, $rW, $rH), "Img: {$iW} x {$iH} Ratio: {$rW} x {$rH}");
//10
$iW = 403; $iH = 3000; //Input image size
$rW = 3; $rH = 4; //ratio
$eW = 402; $eH = 536; //Expected
$this->assertEquals(array($eW, $eH), $img->findBestSizeForRatio($iW, $iH, $rW, $rH), "Img: {$iW} x {$iH} Ratio: {$rW} x {$rH}");
//11
$iW = 4000; $iH = 302; //Input image size
$rW = 3; $rH = 4; //ratio.
$eW = 225; $eH = 300; //Expected
$this->assertEquals(array($eW, $eH), $img->findBestSizeForRatio($iW, $iH, $rW, $rH), "Img: {$iW} x {$iH} Ratio: {$rW} x {$rH}");
//12
$iW = 4000; $iH = 302; //Input image size
$rW = 3; $rH = 4; //ratio.
$eW = 225; $eH = 300; //Expected
$this->assertEquals(array($eW, $eH), $img->findBestSizeForRatio($iW, $iH, $rW, $rH), "Img: {$iW} x {$iH} Ratio: {$rW} x {$rH}");
} |
Partager