@@ -133,6 +133,10 @@ private function createUploadedFile($content, $originalName, $mimeType, $error)
133133 $ path = tempnam ($ this ->tmpDir , uniqid ());
134134 file_put_contents ($ path , $ content );
135135
136+ if (class_exists ('Symfony\Component\HttpFoundation\HeaderUtils ' )) {
137+ // Symfony 4.1+
138+ return new UploadedFile ($ path , $ originalName , $ mimeType , $ error , true );
139+ }
136140 return new UploadedFile ($ path , $ originalName , $ mimeType , filesize ($ path ), $ error , true );
137141 }
138142
@@ -141,19 +145,19 @@ public function testCreateResponse()
141145 $ response = new Response (
142146 'Response content. ' ,
143147 202 ,
144- array ('X-Symfony ' => array ('2.8 ' ))
148+ array ('X-Symfony ' => array ('3.4 ' ))
145149 );
146150 $ response ->headers ->setCookie (new Cookie ('city ' , 'Lille ' , new \DateTime ('Wed, 13 Jan 2021 22:23:01 GMT ' )));
147151
148152 $ psrResponse = $ this ->factory ->createResponse ($ response );
149153 $ this ->assertEquals ('Response content. ' , $ psrResponse ->getBody ()->__toString ());
150154 $ this ->assertEquals (202 , $ psrResponse ->getStatusCode ());
151- $ this ->assertEquals (array ('2.8 ' ), $ psrResponse ->getHeader ('X-Symfony ' ));
155+ $ this ->assertEquals (array ('3.4 ' ), $ psrResponse ->getHeader ('X-Symfony ' ));
152156
153157 $ cookieHeader = $ psrResponse ->getHeader ('Set-Cookie ' );
154158 $ this ->assertInternalType ('array ' , $ cookieHeader );
155159 $ this ->assertCount (1 , $ cookieHeader );
156- $ this ->assertRegExp ('{city=Lille; expires=Wed, 13-Jan-2021 22:23:01 GMT;( max-age=\d+;)? path=/; httponly} ' , $ cookieHeader [0 ]);
160+ $ this ->assertRegExp ('{city=Lille; expires=Wed, 13-Jan-2021 22:23:01 GMT;( max-age=\d+;)? path=/; httponly}i ' , $ cookieHeader [0 ]);
157161 }
158162
159163 public function testCreateResponseFromStreamed ()
@@ -185,11 +189,15 @@ public function testCreateResponseFromBinaryFile()
185189
186190 public function testUploadErrNoFile ()
187191 {
188- $ file = new UploadedFile ('' , '' , null , 0 , UPLOAD_ERR_NO_FILE , true );
192+ if (class_exists ('Symfony\Component\HttpFoundation\HeaderUtils ' )) {
193+ // Symfony 4.1+
194+ $ file = new UploadedFile ('' , '' , null , UPLOAD_ERR_NO_FILE , true );
195+ } else {
196+ $ file = new UploadedFile ('' , '' , null , 0 , UPLOAD_ERR_NO_FILE , true );
197+ }
189198 $ this ->assertEquals (0 , $ file ->getSize ());
190199 $ this ->assertEquals (UPLOAD_ERR_NO_FILE , $ file ->getError ());
191200 $ this ->assertFalse ($ file ->getSize (), 'SplFile::getSize() returns false on error ' );
192- $ this ->assertInternalType ('integer ' , $ file ->getClientSize ());
193201
194202 $ request = new Request (array (), array (), array (), array (),
195203 array (
0 commit comments