@@ -161,4 +161,38 @@ public function testCreateResponseFromBinaryFile()
161161
162162 $ this ->assertEquals ('Binary ' , $ psrResponse ->getBody ()->__toString ());
163163 }
164+
165+ public function testUploadErrNoFile ()
166+ {
167+ $ file = new UploadedFile (null , null , null , 0 , UPLOAD_ERR_NO_FILE , true );
168+ $ this ->assertEquals (0 ,$ file ->getSize ());
169+ $ this ->assertEquals (UPLOAD_ERR_NO_FILE ,$ file ->getError ());
170+
171+ // SplFile returns false on error
172+ $ this ->assertEquals ('boolean ' ,gettype (($ file ->getSize ())));
173+ $ this ->assertFalse ($ file ->getSize ());
174+
175+ // This is an integer, oddly enough internally size is declared as a string
176+ $ this ->assertTrue (is_int ($ file ->getClientSize ()));
177+
178+ $ request = new Request (array (),array (),array (),array (),
179+ array (
180+ 'f1 ' => $ file ,
181+ 'f2 ' => array ('name ' => null , 'type ' => null , 'tmp_name ' => null , 'error ' => UPLOAD_ERR_NO_FILE , 'size ' => 0 ),
182+ ),
183+ array (
184+ 'REQUEST_METHOD ' => 'POST ' ,
185+ 'HTTP_HOST ' => 'dunglas.fr ' ,
186+ 'HTTP_X_SYMFONY ' => '2.8 ' ,
187+ ),
188+ 'Content '
189+ );
190+
191+ $ psrRequest = $ this ->factory ->createRequest ($ request );
192+
193+ $ uploadedFiles = $ psrRequest ->getUploadedFiles ();
194+
195+ $ this ->assertEquals (UPLOAD_ERR_NO_FILE , $ uploadedFiles ['f1 ' ]->getError ());
196+ $ this ->assertEquals (UPLOAD_ERR_NO_FILE , $ uploadedFiles ['f2 ' ]->getError ());
197+ }
164198}
0 commit comments