@@ -688,6 +688,39 @@ public function testUploadEmptyFile()
688688 $ this ->assertSame ('' , (string )$ file ->getStream ());
689689 }
690690
691+ public function testUploadTooLargeFile ()
692+ {
693+ $ boundary = "---------------------------12758086162038677464950549563 " ;
694+
695+ $ data = "-- $ boundary \r\n" ;
696+ $ data .= "Content-Disposition: form-data; name= \"file \"; filename= \"hello \"\r\n" ;
697+ $ data .= "Content-type: text/plain \r\n" ;
698+ $ data .= "\r\n" ;
699+ $ data .= "world \r\n" ;
700+ $ data .= "-- $ boundary-- \r\n" ;
701+
702+ $ request = new ServerRequest ('POST ' , 'http://example.com/ ' , array (
703+ 'Content-Type ' => 'multipart/form-data; boundary= ' . $ boundary ,
704+ ), $ data , 1.1 );
705+
706+ $ parser = new MultipartParser (4 );
707+ $ parsedRequest = $ parser ->parse ($ request );
708+
709+ $ files = $ parsedRequest ->getUploadedFiles ();
710+
711+ $ this ->assertCount (1 , $ files );
712+ $ this ->assertTrue (isset ($ files ['file ' ]));
713+ $ this ->assertInstanceOf ('Psr\Http\Message\UploadedFileInterface ' , $ files ['file ' ]);
714+
715+ /* @var $file \Psr\Http\Message\UploadedFileInterface */
716+ $ file = $ files ['file ' ];
717+
718+ $ this ->assertSame ('hello ' , $ file ->getClientFilename ());
719+ $ this ->assertSame ('text/plain ' , $ file ->getClientMediaType ());
720+ $ this ->assertSame (5 , $ file ->getSize ());
721+ $ this ->assertSame (UPLOAD_ERR_INI_SIZE , $ file ->getError ());
722+ }
723+
691724 public function testUploadNoFile ()
692725 {
693726 $ boundary = "---------------------------12758086162038677464950549563 " ;
0 commit comments