minor #41614 [Mime] Fix CSV file mime type guess test for PHP 8.1 (alexandre-daubois)

This PR was merged into the 4.4 branch.

Discussion
----------

[Mime] Fix CSV file mime type guess test for PHP 8.1

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Part of #41552 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | N/A

I had the same result as `@derrabus` on my computer: `application/csv`. The CI returns `text/csv`. These two seem possible, although `text/csv` is described in [RFC 7111](https://datatracker.ietf.org/doc/html/rfc7111#page-3).

(Oops little typo in title, thanks Alexander for the fix 🙏 )

Commits
-------

117cb8f085 [DependencyInjection] Fix CSV file mime type guess test for PHP 8.1
This commit is contained in:
Nicolas Grekas 2021-06-09 09:43:15 +02:00
commit 7445c3eaab
2 changed files with 8 additions and 4 deletions

View File

@ -65,8 +65,7 @@ class MimeTypeTest extends TestCase
public function testGuessWithDuplicatedFileType()
{
$type = MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.docx');
$this->assertTrue(\in_array($type, ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip'], true));
$this->assertContains(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.docx'), ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip']);
}
public function testGuessWithIncorrectPath()

View File

@ -75,7 +75,12 @@ class MimeTypesTest extends AbstractMimeTypeGuesserTest
}
/**
* PHP 8 detects .csv files as "application/csv" while PHP 7 returns "text/plain".
* PHP 8 detects .csv files as "application/csv" (or "text/csv", depending
* on your system) while PHP 7 returns "text/plain".
*
* "text/csv" is described by RFC 7111.
*
* @see https://datatracker.ietf.org/doc/html/rfc7111
*
* @requires PHP 8
*/
@ -84,7 +89,7 @@ class MimeTypesTest extends AbstractMimeTypeGuesserTest
$mt = new MimeTypes();
$mime = $mt->guessMimeType(__DIR__.'/Fixtures/mimetypes/abc.csv');
$this->assertSame('application/csv', $mime);
$this->assertContains($mime, ['application/csv', 'text/csv']);
$this->assertSame(['csv'], $mt->getExtensions($mime));
}
}