Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mime] handle passing custom mime types as string #36716

Merged
merged 1 commit into from May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Component/Mime/MimeTypes.php
Expand Up @@ -51,7 +51,7 @@ public function __construct(array $map = [])
$this->extensions[$mimeType] = $extensions;
mcneely marked this conversation as resolved.
Show resolved Hide resolved

foreach ($extensions as $extension) {
$this->mimeTypes[$extension] = $mimeType;
$this->mimeTypes[$extension][] = $mimeType;
}
}
$this->registerGuesser(new FileBinaryMimeTypeGuesser());
Expand Down
11 changes: 11 additions & 0 deletions src/Symfony/Component/Mime/Tests/MimeTypesTest.php
Expand Up @@ -62,4 +62,15 @@ public function testGetMimeTypes()
$this->assertContains('image/svg', $mt->getMimeTypes('svg'));
$this->assertSame([], $mt->getMimeTypes('symfony'));
}

public function testCustomMimeTypes()
{
$mt = new MimeTypes([
'text/bar' => ['foo'],
'text/baz' => ['foo', 'moof'],
]);
$this->assertContains('text/bar', $mt->getMimeTypes('foo'));
$this->assertContains('text/baz', $mt->getMimeTypes('foo'));
$this->assertSame(['foo', 'moof'], $mt->getExtensions('text/baz'));
}
}