@@ -139,6 +139,28 @@ public function testResizeToWidth()
139
139
$ this ->assertEquals (50 , $ resize ->getDestHeight ());
140
140
}
141
141
142
+ public function testResizeToBestFit ()
143
+ {
144
+ $ image = $ this ->createImage (200 , 500 , 'png ' );
145
+ $ resize = new ImageResize ($ image );
146
+
147
+ $ resize ->resizeToBestFit (100 , 100 );
148
+
149
+ $ this ->assertEquals (40 , $ resize ->getDestWidth ());
150
+ $ this ->assertEquals (100 , $ resize ->getDestHeight ());
151
+ }
152
+
153
+ public function testResizeToBestFitNoEnlarge ()
154
+ {
155
+ $ image = $ this ->createImage (200 , 100 , 'png ' );
156
+ $ resize = new ImageResize ($ image );
157
+
158
+ $ resize ->resizeToBestFit (250 , 250 );
159
+
160
+ $ this ->assertEquals (200 , $ resize ->getDestWidth ());
161
+ $ this ->assertEquals (100 , $ resize ->getDestHeight ());
162
+ }
163
+
142
164
public function testScale ()
143
165
{
144
166
$ image = $ this ->createImage (200 , 100 , 'png ' );
@@ -172,7 +194,6 @@ public function testResizeLargerNotAllowed()
172
194
$ this ->assertEquals (100 , $ resize ->getDestHeight ());
173
195
}
174
196
175
-
176
197
/**
177
198
* Crop tests
178
199
*/
0 commit comments