Skip to content

Commit

Permalink
bug #36716 [Mime] handle passing custom mime types as string (mcneely)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

[Mime] handle passing custom mime types as string

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #36715
| License       | MIT
| Doc PR        | none
Fix's issue where custom mimetypes were failing

Commits
-------

f3005ec Fix for #36715
  • Loading branch information
fabpot committed May 9, 2020
2 parents 99d5818 + f3005ec commit 6310084
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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;

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'));
}
}

0 comments on commit 6310084

Please sign in to comment.