@@ -36,7 +36,7 @@ final class FormatTest extends TestCase
3636
3737 $ applicator = new Format ();
3838
39- Assert::null ( $ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config ));
39+ Assert::same ([], iterator_to_array ( $ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config) ));
4040 }
4141
4242 public function testNullShouldBeReturnedIfQualityIsNotSpecifiedAndPathInfoExtensionIsNull (): void
@@ -52,58 +52,50 @@ final class FormatTest extends TestCase
5252
5353 $ applicator = new Format ();
5454
55- Assert::null ( $ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config ));
55+ Assert::same ([], iterator_to_array ( $ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config) ));
5656 }
5757
5858 public function testImageShouldBeEncodedInDefaultFormatIfPathInfoExtensionIsNullAndImageMimeTypeIsUnsupported (): void
5959 {
6060 $ image = Mockery::mock (Image::class);
6161 $ pathInfo = $ this ->createPathInfo (null );
6262 $ modifierValues = $ this ->createModifierValues (null );
63- $ config = $ this -> createConfigForEncode ( );
63+ $ config = Mockery:: mock (ConfigInterface::class );
6464
6565 $ image ->shouldReceive ('mime ' )
6666 ->withNoArgs ()
6767 ->andReturn ('image/unsupported ' );
6868
6969 $ modifiedImage = $ this ->setupJpgExpectationsOnImage ($ image , false );
7070
71- $ modifiedImage ->shouldReceive ('encode ' )
72- ->once ()
73- ->with ('jpg ' , 90 )
74- ->andReturn ($ modifiedImage );
75-
7671 $ applicator = new Format ();
7772
78- Assert::same ($ modifiedImage , $ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config ));
73+ $ result = iterator_to_array ($ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config ));
74+ Assert::same ($ modifiedImage , $ result ['image ' ]);
75+ Assert::same ('jpg ' , $ result ['format ' ]);
7976 }
8077
8178 public function testImageShouldBeEncodedIfPathInfoExtensionIsDifferentThanImageMimeType (): void
8279 {
8380 $ image = Mockery::mock (Image::class);
84- $ modifiedImage = Mockery::mock (Image::class);
8581 $ pathInfo = $ this ->createPathInfo ('webp ' );
8682 $ modifierValues = $ this ->createModifierValues (null );
87- $ config = $ this -> createConfigForEncode ( );
83+ $ config = Mockery:: mock (ConfigInterface::class );
8884
8985 $ image ->shouldReceive ('mime ' )
9086 ->withNoArgs ()
9187 ->andReturn ('image/jpeg ' );
9288
93- $ image ->shouldReceive ('encode ' )
94- ->once ()
95- ->with ('webp ' , 90 )
96- ->andReturn ($ modifiedImage );
97-
9889 $ applicator = new Format ();
9990
100- Assert::same ($ modifiedImage , $ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config ));
91+ $ result = iterator_to_array ($ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config ));
92+ Assert::same ($ image , $ result ['image ' ]);
93+ Assert::same ('webp ' , $ result ['format ' ]);
10194 }
10295
10396 public function testImageShouldBeEncodedIfQualityIsSpecified (): void
10497 {
10598 $ image = Mockery::mock (Image::class);
106- $ modifiedImage = Mockery::mock (Image::class);
10799 $ pathInfo = $ this ->createPathInfo (null );
108100 $ modifierValues = $ this ->createModifierValues (75 );
109101 $ config = Mockery::mock (ConfigInterface::class);
@@ -112,37 +104,32 @@ final class FormatTest extends TestCase
112104 ->withNoArgs ()
113105 ->andReturn ('image/png ' );
114106
115- $ image ->shouldReceive ('encode ' )
116- ->once ()
117- ->with ('png ' , 75 )
118- ->andReturn ($ modifiedImage );
119-
120107 $ applicator = new Format ();
121108
122- Assert::same ($ modifiedImage , $ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config ));
109+ $ result = iterator_to_array ($ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config ));
110+ Assert::same ($ image , $ result ['image ' ]);
111+ Assert::same ('png ' , $ result ['format ' ]);
112+ Assert::same (75 , $ result ['quality ' ]);
123113 }
124114
125115 public function testImageShouldBeEncodedToJpegFromDifferentFormat (): void
126116 {
127117 $ image = Mockery::mock (Image::class);
128118 $ pathInfo = $ this ->createPathInfo ('jpg ' );
129119 $ modifierValues = $ this ->createModifierValues (null );
130- $ config = $ this -> createConfigForEncode ( );
120+ $ config = Mockery:: mock (ConfigInterface::class );
131121
132122 $ image ->shouldReceive ('mime ' )
133123 ->withNoArgs ()
134124 ->andReturn ('image/png ' );
135125
136126 $ modifiedImage = $ this ->setupJpgExpectationsOnImage ($ image , false );
137127
138- $ modifiedImage ->shouldReceive ('encode ' )
139- ->once ()
140- ->with ('jpg ' , 90 )
141- ->andReturn ($ modifiedImage );
142-
143128 $ applicator = new Format ();
144129
145- Assert::same ($ modifiedImage , $ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config ));
130+ $ result = iterator_to_array ($ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config ));
131+ Assert::same ($ modifiedImage , $ result ['image ' ]);
132+ Assert::same ('jpg ' , $ result ['format ' ]);
146133 }
147134
148135 /**
@@ -153,7 +140,7 @@ final class FormatTest extends TestCase
153140 $ image = Mockery::mock (Image::class);
154141 $ pathInfo = $ this ->createPathInfo ('pjpg ' );
155142 $ modifierValues = $ this ->createModifierValues (null );
156- $ config = $ this -> createConfigForEncode ( );
143+ $ config = Mockery:: mock (ConfigInterface::class );
157144
158145 $ image ->shouldReceive ('mime ' )
159146 ->withNoArgs ()
@@ -165,14 +152,11 @@ final class FormatTest extends TestCase
165152
166153 $ modifiedImage = $ this ->setupJpgExpectationsOnImage ($ image , true );
167154
168- $ modifiedImage ->shouldReceive ('encode ' )
169- ->once ()
170- ->with ('jpg ' , 90 )
171- ->andReturn ($ modifiedImage );
172-
173155 $ applicator = new Format ();
174156
175- Assert::same ($ modifiedImage , $ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config ));
157+ $ result = iterator_to_array ($ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config ));
158+ Assert::same ($ modifiedImage , $ result ['image ' ]);
159+ Assert::same ('jpg ' , $ result ['format ' ]);
176160 }
177161
178162 public function testImageShouldNotBeEncodedToProgressiveJpeg (): void
@@ -198,7 +182,7 @@ final class FormatTest extends TestCase
198182
199183 $ applicator = new Format ();
200184
201- Assert::null ( $ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config ));
185+ Assert::same ([], iterator_to_array ( $ applicator ->apply ($ image , $ pathInfo , $ modifierValues , $ config) ));
202186 }
203187
204188 public function provideImageCoresForProgressiveJpegWithInvalidInterlaceScheme (): array
0 commit comments