mirror of
https://github.com/Intervention/image.git
synced 2025-03-15 22:49:40 +01:00
New unit tests for new resize function
Signed-off-by: Dries Vints <dries.vints@gmail.com>
This commit is contained in:
parent
fcfa9c0a04
commit
284b4517fb
@ -38,6 +38,26 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
||||
$this->assertEquals($img->width, 320);
|
||||
$this->assertEquals($img->height, 240);
|
||||
|
||||
// Only resize the width.
|
||||
$img = $this->getTestImage();
|
||||
$img->resize(320);
|
||||
$height = $img->height;
|
||||
$this->assertInternalType('int', $img->width);
|
||||
$this->assertInternalType('int', $img->height);
|
||||
$this->assertEquals($img->width, 320);
|
||||
// Check if the height is still the same.
|
||||
$this->assertEquals($img->height, $height);
|
||||
|
||||
// Only resize the width.
|
||||
$img = $this->getTestImage();
|
||||
$img->resize(null, 240);
|
||||
$width = $img->width;
|
||||
$this->assertInternalType('int', $img->width);
|
||||
$this->assertInternalType('int', $img->height);
|
||||
// Check if the width is still the same.
|
||||
$this->assertEquals($img->width, $width);
|
||||
$this->assertEquals($img->height, 240);
|
||||
|
||||
// auto height
|
||||
$img = $this->getTestImage();
|
||||
$img->resize(320, null, true);
|
||||
@ -53,6 +73,22 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
||||
$this->assertInternalType('int', $img->height);
|
||||
$this->assertEquals($img->width, 320);
|
||||
$this->assertEquals($img->height, 240);
|
||||
|
||||
// Test image upsizing.
|
||||
$img = $this->getTestImage();
|
||||
// Keep original width and height.
|
||||
$original_width = $img->width;
|
||||
$original_height = $img->height;
|
||||
// Increase values a bit.
|
||||
$width = $original_width + 500;
|
||||
$height = $original_height + 350;
|
||||
// Try resizing to higher values while upsizing is set to false.
|
||||
$img->resize($width, $height, false, false);
|
||||
$this->assertInternalType('int', $img->width);
|
||||
$this->assertInternalType('int', $img->height);
|
||||
// Check if width and height are still the same.
|
||||
$this->assertEquals($img->width, $original_width);
|
||||
$this->assertEquals($img->height, $original_height);
|
||||
}
|
||||
|
||||
public function testGrabImage()
|
||||
|
Loading…
x
Reference in New Issue
Block a user