Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7445c3e

Browse filesBrowse files
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 ------- 117cb8f [DependencyInjection] Fix CSV file mime type guess test for PHP 8.1
2 parents 7957b48 + 117cb8f commit 7445c3e
Copy full SHA for 7445c3e

File tree

2 files changed

+8
-4
lines changed
Filter options

2 files changed

+8
-4
lines changed

‎src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ public function testGuessFileWithUnknownExtension()
6565

6666
public function testGuessWithDuplicatedFileType()
6767
{
68-
$type = MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.docx');
69-
$this->assertTrue(\in_array($type, ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip'], true));
68+
$this->assertContains(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.docx'), ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip']);
7069
}
7170

7271
public function testGuessWithIncorrectPath()

‎src/Symfony/Component/Mime/Tests/MimeTypesTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Tests/MimeTypesTest.php
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ public function testCustomMimeTypes()
7575
}
7676

7777
/**
78-
* PHP 8 detects .csv files as "application/csv" while PHP 7 returns "text/plain".
78+
* PHP 8 detects .csv files as "application/csv" (or "text/csv", depending
79+
* on your system) while PHP 7 returns "text/plain".
80+
*
81+
* "text/csv" is described by RFC 7111.
82+
*
83+
* @see https://datatracker.ietf.org/doc/html/rfc7111
7984
*
8085
* @requires PHP 8
8186
*/
@@ -84,7 +89,7 @@ public function testCsvExtension()
8489
$mt = new MimeTypes();
8590

8691
$mime = $mt->guessMimeType(__DIR__.'/Fixtures/mimetypes/abc.csv');
87-
$this->assertSame('application/csv', $mime);
92+
$this->assertContains($mime, ['application/csv', 'text/csv']);
8893
$this->assertSame(['csv'], $mt->getExtensions($mime));
8994
}
9095
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.