From 02f74822f60d1badde57c7871cfa9c7838aea54c Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sun, 24 Feb 2013 19:54:44 +0100 Subject: [PATCH] added more tests for new resize method --- tests/ImageTest.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/ImageTest.php b/tests/ImageTest.php index 5359ad5a..aa088762 100644 --- a/tests/ImageTest.php +++ b/tests/ImageTest.php @@ -40,8 +40,8 @@ class ImageTest extends PHPUnit_Framework_Testcase // Only resize the width. $img = $this->getTestImage(); - $img->resize(320); $height = $img->height; + $img->resize(320); $this->assertInternalType('int', $img->width); $this->assertInternalType('int', $img->height); $this->assertEquals($img->width, 320); @@ -50,8 +50,8 @@ class ImageTest extends PHPUnit_Framework_Testcase // Only resize the width. $img = $this->getTestImage(); - $img->resize(null, 240); $width = $img->width; + $img->resize(null, 240); $this->assertInternalType('int', $img->width); $this->assertInternalType('int', $img->height); // Check if the width is still the same. @@ -74,6 +74,22 @@ class ImageTest extends PHPUnit_Framework_Testcase $this->assertEquals($img->width, 320); $this->assertEquals($img->height, 240); + // preserve simple upsizing + $img = $this->getTestImage(); + $img->resize(1000, 1000, true, false); + $this->assertInternalType('int', $img->width); + $this->assertInternalType('int', $img->height); + $this->assertEquals($img->width, 800); + $this->assertEquals($img->height, 600); + + // test dominant width for auto-resizing + $img = $this->getTestImage(); + $img->resize(1000, 1200, true); + $this->assertInternalType('int', $img->width); + $this->assertInternalType('int', $img->height); + $this->assertEquals($img->width, 1000); + $this->assertEquals($img->height, 750); + // Test image upsizing. $img = $this->getTestImage(); // Keep original width and height.