@@ -16,12 +16,10 @@ class ImageResizeTest extends PHPUnit_Framework_TestCase
16
16
private $ unsupported_image = 'Qk08AAAAAAAAADYAAAAoAAAAAQAAAAEAAAABABAAAAAAAAYAAAASCwAAEgsAAAAAAAAAAAAA/38AAAAA ' ;
17
17
private $ image_string = 'R0lGODlhAQABAIAAAAQCBP///yH5BAEAAAEALAAAAAABAAEAAAICRAEAOw== ' ;
18
18
19
- public function testLoadString () {
20
- $ resize = ImageResize::createFromString (base64_decode ($ this ->image_string ));
21
19
22
- $ this -> assertEquals ( IMAGETYPE_GIF , $ resize -> source_type );
23
- $ this -> assertInstanceOf ( ' \Eventviva\ImageResize ' , $ resize );
24
- }
20
+ /**
21
+ * Loading tests
22
+ */
25
23
26
24
public function testLoadGif () {
27
25
$ image = $ this ->createImage (1 , 1 , 'gif ' );
@@ -47,13 +45,17 @@ public function testLoadPng() {
47
45
$ this ->assertInstanceOf ('\Eventviva\ImageResize ' , $ resize );
48
46
}
49
47
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
+
50
56
/**
51
- * @expectedException Exception
52
- * @expectedExceptionMessage Unsupported image type
57
+ * Bad load tests
53
58
*/
54
- public function testInvalidString () {
55
- ImageResize::createFromString (base64_decode ($ this ->unsupported_image ));
56
- }
57
59
58
60
/**
59
61
* @expectedException Exception
@@ -93,6 +95,19 @@ public function testLoadUnsupportedImage() {
93
95
new ImageResize ($ filename );
94
96
}
95
97
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
+
96
111
public function testResizeToHeight () {
97
112
$ image = $ this ->createImage (200 , 100 , 'png ' );
98
113
$ resize = new ImageResize ($ image );
@@ -143,6 +158,11 @@ public function testResizeLargerNotAllowed() {
143
158
$ this ->assertEquals (100 , $ resize ->getDestHeight ());
144
159
}
145
160
161
+
162
+ /**
163
+ * Crop tests
164
+ */
165
+
146
166
public function testCrop () {
147
167
$ image = $ this ->createImage (200 , 100 , 'png ' );
148
168
$ resize = new ImageResize ($ image );
@@ -176,6 +196,11 @@ public function testCropLargerNotAllowed() {
176
196
$ this ->assertEquals (100 , $ resize ->getDestHeight ());
177
197
}
178
198
199
+
200
+ /**
201
+ * Save tests
202
+ */
203
+
179
204
public function testSaveGif () {
180
205
$ image = $ this ->createImage (200 , 100 , 'gif ' );
181
206
@@ -224,6 +249,11 @@ public function testSaveChmod() {
224
249
$ this ->assertEquals (600 , substr (decoct (fileperms ($ filename )), 3 ));
225
250
}
226
251
252
+
253
+ /**
254
+ * String test
255
+ */
256
+
227
257
public function testGetImageAsString () {
228
258
$ resize = ImageResize::createFromString (base64_decode ($ this ->image_string ));
229
259
$ image = $ resize ->getImageAsString ();
@@ -236,6 +266,11 @@ public function testToString() {
236
266
$ this ->assertEquals (43 , strlen ($ image ));
237
267
}
238
268
269
+
270
+ /**
271
+ * Output tests
272
+ */
273
+
239
274
public function testOutputGif () {
240
275
$ image = $ this ->createImage (200 , 100 , 'gif ' );
241
276
@@ -293,6 +328,11 @@ public function testOutputPng() {
293
328
$ this ->assertEquals ('image/png ' , $ type );
294
329
}
295
330
331
+
332
+ /**
333
+ * Helpers
334
+ */
335
+
296
336
private function createImage ($ width , $ height , $ type ) {
297
337
if (!in_array ($ type , $ this ->image_types )) {
298
338
throw new \Exception ('Unsupported image type ' );
0 commit comments