FilenameToTypeTest: add some additional test cases

... which should be supported based on the function docs.

Note: the "empty string" test may need looking at.... is this a bug ?
This commit is contained in:
jrfnl 2021-06-25 16:53:19 +02:00
parent 6ba68af48c
commit 76aa6a06cb
1 changed files with 16 additions and 0 deletions

View File

@ -44,10 +44,26 @@ final class FilenameToTypeTest extends TestCase
public function dataFilenameToType()
{
return [
'Empty string' => [
'filename' => '',
'expected' => 'application/octet-stream',
],
'File name without query string' => [
'filename' => 'abc.png',
'expected' => 'image/png',
],
'File name with query string' => [
'filename' => 'abc.jpg?xyz=1',
'expected' => 'image/jpeg',
],
'Full path to file, linux style' => [
'filename' => '/usr/sbin/subdir/docs.pdf',
'expected' => 'application/pdf',
],
'Full path to file, windows style' => [
'filename' => 'D:\subdir\with spaces\subdir\myapp.zip',
'expected' => 'application/zip',
],
'Unknown extension, should return default MIME type' => [
'filename' => 'abc.xyzpdq',
'expected' => 'application/octet-stream',