@@ -21,31 +21,35 @@ class ImageResizeTest extends PHPUnit_Framework_TestCase
21
21
* Loading tests
22
22
*/
23
23
24
- public function testLoadGif () {
24
+ public function testLoadGif ()
25
+ {
25
26
$ image = $ this ->createImage (1 , 1 , 'gif ' );
26
27
$ resize = ImageResize::createFromFile ($ image );
27
28
28
29
$ this ->assertEquals (IMAGETYPE_GIF , $ resize ->source_type );
29
30
$ this ->assertInstanceOf ('\Eventviva\ImageResize ' , $ resize );
30
31
}
31
32
32
- public function testLoadJpg () {
33
+ public function testLoadJpg ()
34
+ {
33
35
$ image = $ this ->createImage (1 , 1 , 'jpeg ' );
34
36
$ resize = ImageResize::createFromFile ($ image );
35
37
36
38
$ this ->assertEquals (IMAGETYPE_JPEG , $ resize ->source_type );
37
39
$ this ->assertInstanceOf ('\Eventviva\ImageResize ' , $ resize );
38
40
}
39
41
40
- public function testLoadPng () {
42
+ public function testLoadPng ()
43
+ {
41
44
$ image = $ this ->createImage (1 , 1 , 'png ' );
42
45
$ resize = ImageResize::createFromFile ($ image );
43
46
44
47
$ this ->assertEquals (IMAGETYPE_PNG , $ resize ->source_type );
45
48
$ this ->assertInstanceOf ('\Eventviva\ImageResize ' , $ resize );
46
49
}
47
50
48
- public function testLoadString () {
51
+ public function testLoadString ()
52
+ {
49
53
$ resize = ImageResize::createFromString (base64_decode ($ this ->image_string ));
50
54
51
55
$ this ->assertEquals (IMAGETYPE_GIF , $ resize ->source_type );
@@ -61,31 +65,35 @@ public function testLoadString() {
61
65
* @expectedException Exception
62
66
* @expectedExceptionMessage No image provided
63
67
*/
64
- public function testLoadNoFile () {
68
+ public function testLoadNoFile ()
69
+ {
65
70
new ImageResize (null );
66
71
}
67
72
68
73
/**
69
74
* @expectedException Exception
70
75
* @expectedExceptionMessage Could not read
71
76
*/
72
- public function testLoadUnsupportedFile () {
77
+ public function testLoadUnsupportedFile ()
78
+ {
73
79
new ImageResize (__FILE__ );
74
80
}
75
81
76
82
/**
77
83
* @expectedException Exception
78
84
* @expectedExceptionMessage Could not load
79
85
*/
80
- public function testLoadUnsupportedFileString () {
86
+ public function testLoadUnsupportedFileString ()
87
+ {
81
88
ImageResize::createFromString ('' );
82
89
}
83
90
84
91
/**
85
92
* @expectedException Exception
86
93
* @expectedExceptionMessage Unsupported image type
87
94
*/
88
- public function testLoadUnsupportedImage () {
95
+ public function testLoadUnsupportedImage ()
96
+ {
89
97
$ filename = $ this ->getTempFile ();
90
98
91
99
$ image = fopen ($ filename , 'w ' );
@@ -99,7 +107,8 @@ public function testLoadUnsupportedImage() {
99
107
* @expectedException Exception
100
108
* @expectedExceptionMessage Unsupported image type
101
109
*/
102
- public function testInvalidString () {
110
+ public function testInvalidString ()
111
+ {
103
112
ImageResize::createFromString (base64_decode ($ this ->unsupported_image ));
104
113
}
105
114
@@ -108,7 +117,8 @@ public function testInvalidString() {
108
117
* Resize tests
109
118
*/
110
119
111
- public function testResizeToHeight () {
120
+ public function testResizeToHeight ()
121
+ {
112
122
$ image = $ this ->createImage (200 , 100 , 'png ' );
113
123
$ resize = new ImageResize ($ image );
114
124
@@ -118,7 +128,8 @@ public function testResizeToHeight() {
118
128
$ this ->assertEquals (50 , $ resize ->getDestHeight ());
119
129
}
120
130
121
- public function testResizeToWidth () {
131
+ public function testResizeToWidth ()
132
+ {
122
133
$ image = $ this ->createImage (200 , 100 , 'png ' );
123
134
$ resize = new ImageResize ($ image );
124
135
@@ -128,7 +139,8 @@ public function testResizeToWidth() {
128
139
$ this ->assertEquals (50 , $ resize ->getDestHeight ());
129
140
}
130
141
131
- public function testScale () {
142
+ public function testScale ()
143
+ {
132
144
$ image = $ this ->createImage (200 , 100 , 'png ' );
133
145
$ resize = new ImageResize ($ image );
134
146
@@ -138,7 +150,8 @@ public function testScale() {
138
150
$ this ->assertEquals (50 , $ resize ->getDestHeight ());
139
151
}
140
152
141
- public function testResize () {
153
+ public function testResize ()
154
+ {
142
155
$ image = $ this ->createImage (200 , 100 , 'png ' );
143
156
$ resize = new ImageResize ($ image );
144
157
@@ -148,7 +161,8 @@ public function testResize() {
148
161
$ this ->assertEquals (50 , $ resize ->getDestHeight ());
149
162
}
150
163
151
- public function testResizeLargerNotAllowed () {
164
+ public function testResizeLargerNotAllowed ()
165
+ {
152
166
$ image = $ this ->createImage (200 , 100 , 'png ' );
153
167
$ resize = new ImageResize ($ image );
154
168
@@ -163,7 +177,8 @@ public function testResizeLargerNotAllowed() {
163
177
* Crop tests
164
178
*/
165
179
166
- public function testCrop () {
180
+ public function testCrop ()
181
+ {
167
182
$ image = $ this ->createImage (200 , 100 , 'png ' );
168
183
$ resize = new ImageResize ($ image );
169
184
@@ -173,7 +188,8 @@ public function testCrop() {
173
188
$ this ->assertEquals (50 , $ resize ->getDestHeight ());
174
189
}
175
190
176
- public function testCropPosition () {
191
+ public function testCropPosition ()
192
+ {
177
193
$ image = $ this ->createImage (200 , 100 , 'png ' );
178
194
$ resize = new ImageResize ($ image );
179
195
@@ -186,7 +202,8 @@ public function testCropPosition() {
186
202
$ this ->assertEquals (100 , $ source_x ->getValue ($ resize ));
187
203
}
188
204
189
- public function testCropLargerNotAllowed () {
205
+ public function testCropLargerNotAllowed ()
206
+ {
190
207
$ image = $ this ->createImage (200 , 100 , 'png ' );
191
208
$ resize = new ImageResize ($ image );
192
209
@@ -201,7 +218,8 @@ public function testCropLargerNotAllowed() {
201
218
* Save tests
202
219
*/
203
220
204
- public function testSaveGif () {
221
+ public function testSaveGif ()
222
+ {
205
223
$ image = $ this ->createImage (200 , 100 , 'gif ' );
206
224
207
225
$ resize = new ImageResize ($ image );
@@ -213,7 +231,8 @@ public function testSaveGif() {
213
231
$ this ->assertEquals (IMAGETYPE_GIF , exif_imagetype ($ filename ));
214
232
}
215
233
216
- public function testSaveJpg () {
234
+ public function testSaveJpg ()
235
+ {
217
236
$ image = $ this ->createImage (200 , 100 , 'jpeg ' );
218
237
219
238
$ resize = new ImageResize ($ image );
@@ -225,7 +244,8 @@ public function testSaveJpg() {
225
244
$ this ->assertEquals (IMAGETYPE_JPEG , exif_imagetype ($ filename ));
226
245
}
227
246
228
- public function testSavePng () {
247
+ public function testSavePng ()
248
+ {
229
249
$ image = $ this ->createImage (200 , 100 , 'png ' );
230
250
231
251
$ resize = new ImageResize ($ image );
@@ -237,7 +257,8 @@ public function testSavePng() {
237
257
$ this ->assertEquals (IMAGETYPE_PNG , exif_imagetype ($ filename ));
238
258
}
239
259
240
- public function testSaveChmod () {
260
+ public function testSaveChmod ()
261
+ {
241
262
$ image = $ this ->createImage (200 , 100 , 'png ' );
242
263
243
264
$ resize = new ImageResize ($ image );
@@ -254,13 +275,15 @@ public function testSaveChmod() {
254
275
* String test
255
276
*/
256
277
257
- public function testGetImageAsString () {
278
+ public function testGetImageAsString ()
279
+ {
258
280
$ resize = ImageResize::createFromString (base64_decode ($ this ->image_string ));
259
281
$ image = $ resize ->getImageAsString ();
260
282
$ this ->assertEquals (43 , strlen ($ image ));
261
283
}
262
284
263
- public function testToString () {
285
+ public function testToString ()
286
+ {
264
287
$ resize = ImageResize::createFromString (base64_decode ($ this ->image_string ));
265
288
$ image = (string )$ resize ;
266
289
$ this ->assertEquals (43 , strlen ($ image ));
@@ -271,7 +294,8 @@ public function testToString() {
271
294
* Output tests
272
295
*/
273
296
274
- public function testOutputGif () {
297
+ public function testOutputGif ()
298
+ {
275
299
$ image = $ this ->createImage (200 , 100 , 'gif ' );
276
300
277
301
$ resize = new ImageResize ($ image );
@@ -290,7 +314,8 @@ public function testOutputGif() {
290
314
$ this ->assertEquals ('image/gif ' , $ type );
291
315
}
292
316
293
- public function testOutputJpg () {
317
+ public function testOutputJpg ()
318
+ {
294
319
$ image = $ this ->createImage (200 , 100 , 'jpeg ' );
295
320
296
321
$ resize = new ImageResize ($ image );
@@ -309,7 +334,8 @@ public function testOutputJpg() {
309
334
$ this ->assertEquals ('image/jpeg ' , $ type );
310
335
}
311
336
312
- public function testOutputPng () {
337
+ public function testOutputPng ()
338
+ {
313
339
$ image = $ this ->createImage (200 , 100 , 'png ' );
314
340
315
341
$ resize = new ImageResize ($ image );
@@ -333,7 +359,8 @@ public function testOutputPng() {
333
359
* Helpers
334
360
*/
335
361
336
- private function createImage ($ width , $ height , $ type ) {
362
+ private function createImage ($ width , $ height , $ type )
363
+ {
337
364
if (!in_array ($ type , $ this ->image_types )) {
338
365
throw new \Exception ('Unsupported image type ' );
339
366
}
@@ -348,7 +375,8 @@ private function createImage($width, $height, $type) {
348
375
return $ filename ;
349
376
}
350
377
351
- private function getTempFile () {
378
+ private function getTempFile ()
379
+ {
352
380
return tempnam (sys_get_temp_dir (), 'resize_test_image ' );
353
381
}
354
382
0 commit comments