File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -352,7 +352,7 @@ public function getExtension(): string
352352
353353 public function guessExtension (): ?string
354354 {
355- return \Config \Mimes::guessExtensionFromType ($ this ->getMimeType (), $ this ->getClientExtension ());
355+ return \Config \Mimes::guessExtensionFromType ($ this ->getClientMimeType (), $ this ->getClientExtension ());
356356 }
357357
358358 //--------------------------------------------------------------------
@@ -366,7 +366,7 @@ public function guessExtension(): ?string
366366 */
367367 public function getClientExtension (): string
368368 {
369- return pathinfo ($ this ->originalName , PATHINFO_EXTENSION );
369+ return pathinfo ($ this ->originalName , PATHINFO_EXTENSION ) ?? '' ;
370370 }
371371
372372 //--------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -137,6 +137,38 @@ public function testAllReturnsValidMultipleFilesDifferentName()
137137
138138 //--------------------------------------------------------------------
139139
140+ public function testExtensionGuessing ()
141+ {
142+ $ _FILES = [
143+ 'userfile1 ' => [
144+ 'name ' => 'fileA.txt ' ,
145+ 'type ' => 'text/plain ' ,
146+ 'size ' => 124 ,
147+ 'tmp_name ' => '/fileA.txt ' ,
148+ 'error ' => 0 ,
149+ ],
150+ 'userfile2 ' => [
151+ 'name ' => 'fileB.txt ' ,
152+ 'type ' => 'text/csv ' ,
153+ 'size ' => 248 ,
154+ 'tmp_name ' => '/fileB.txt ' ,
155+ 'error ' => 0 ,
156+ ],
157+ ];
158+
159+ $ collection = new FileCollection ();
160+
161+ $ file = $ collection ->getFile ('userfile1 ' );
162+ $ this ->assertInstanceOf (UploadedFile::class, $ file );
163+ $ this ->assertEquals ('txt ' , $ file ->getExtension ());
164+
165+ $ file = $ collection ->getFile ('userfile2 ' );
166+ $ this ->assertInstanceOf (UploadedFile::class, $ file );
167+ $ this ->assertEquals ('csv ' , $ file ->guessExtension ());
168+ }
169+
170+ //--------------------------------------------------------------------
171+
140172 /**
141173 * @group single
142174 */
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments