Skip to content

Commit bc87124

Browse files
author
Mitch
committed
Testing code cleanup
1 parent 791289e commit bc87124

File tree

1 file changed

+50
-10
lines changed

1 file changed

+50
-10
lines changed

test/Test.php

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ class ImageResizeTest extends PHPUnit_Framework_TestCase
1616
private $unsupported_image = 'Qk08AAAAAAAAADYAAAAoAAAAAQAAAAEAAAABABAAAAAAAAYAAAASCwAAEgsAAAAAAAAAAAAA/38AAAAA';
1717
private $image_string = 'R0lGODlhAQABAIAAAAQCBP///yH5BAEAAAEALAAAAAABAAEAAAICRAEAOw==';
1818

19-
public function testLoadString() {
20-
$resize = ImageResize::createFromString(base64_decode($this->image_string));
2119

22-
$this->assertEquals(IMAGETYPE_GIF, $resize->source_type);
23-
$this->assertInstanceOf('\Eventviva\ImageResize', $resize);
24-
}
20+
/**
21+
* Loading tests
22+
*/
2523

2624
public function testLoadGif() {
2725
$image = $this->createImage(1, 1, 'gif');
@@ -47,13 +45,17 @@ public function testLoadPng() {
4745
$this->assertInstanceOf('\Eventviva\ImageResize', $resize);
4846
}
4947

48+
public function testLoadString() {
49+
$resize = ImageResize::createFromString(base64_decode($this->image_string));
50+
51+
$this->assertEquals(IMAGETYPE_GIF, $resize->source_type);
52+
$this->assertInstanceOf('\Eventviva\ImageResize', $resize);
53+
}
54+
55+
5056
/**
51-
* @expectedException Exception
52-
* @expectedExceptionMessage Unsupported image type
57+
* Bad load tests
5358
*/
54-
public function testInvalidString() {
55-
ImageResize::createFromString(base64_decode($this->unsupported_image));
56-
}
5759

5860
/**
5961
* @expectedException Exception
@@ -93,6 +95,19 @@ public function testLoadUnsupportedImage() {
9395
new ImageResize($filename);
9496
}
9597

98+
/**
99+
* @expectedException Exception
100+
* @expectedExceptionMessage Unsupported image type
101+
*/
102+
public function testInvalidString() {
103+
ImageResize::createFromString(base64_decode($this->unsupported_image));
104+
}
105+
106+
107+
/**
108+
* Resize tests
109+
*/
110+
96111
public function testResizeToHeight() {
97112
$image = $this->createImage(200, 100, 'png');
98113
$resize = new ImageResize($image);
@@ -143,6 +158,11 @@ public function testResizeLargerNotAllowed() {
143158
$this->assertEquals(100, $resize->getDestHeight());
144159
}
145160

161+
162+
/**
163+
* Crop tests
164+
*/
165+
146166
public function testCrop() {
147167
$image = $this->createImage(200, 100, 'png');
148168
$resize = new ImageResize($image);
@@ -176,6 +196,11 @@ public function testCropLargerNotAllowed() {
176196
$this->assertEquals(100, $resize->getDestHeight());
177197
}
178198

199+
200+
/**
201+
* Save tests
202+
*/
203+
179204
public function testSaveGif() {
180205
$image = $this->createImage(200, 100, 'gif');
181206

@@ -224,6 +249,11 @@ public function testSaveChmod() {
224249
$this->assertEquals(600, substr(decoct(fileperms($filename)), 3));
225250
}
226251

252+
253+
/**
254+
* String test
255+
*/
256+
227257
public function testGetImageAsString() {
228258
$resize = ImageResize::createFromString(base64_decode($this->image_string));
229259
$image = $resize->getImageAsString();
@@ -236,6 +266,11 @@ public function testToString() {
236266
$this->assertEquals(43, strlen($image));
237267
}
238268

269+
270+
/**
271+
* Output tests
272+
*/
273+
239274
public function testOutputGif() {
240275
$image = $this->createImage(200, 100, 'gif');
241276

@@ -293,6 +328,11 @@ public function testOutputPng() {
293328
$this->assertEquals('image/png', $type);
294329
}
295330

331+
332+
/**
333+
* Helpers
334+
*/
335+
296336
private function createImage($width, $height, $type) {
297337
if (!in_array($type, $this->image_types)) {
298338
throw new \Exception('Unsupported image type');

0 commit comments

Comments
 (0)