@@ -139,6 +139,28 @@ public function testResizeToWidth()
139139 $ this ->assertEquals (50 , $ resize ->getDestHeight ());
140140 }
141141
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+
142164 public function testScale ()
143165 {
144166 $ image = $ this ->createImage (200 , 100 , 'png ' );
@@ -172,7 +194,6 @@ public function testResizeLargerNotAllowed()
172194 $ this ->assertEquals (100 , $ resize ->getDestHeight ());
173195 }
174196
175-
176197 /**
177198 * Crop tests
178199 */
0 commit comments