Skip to content

Commit a51d354

Browse files
committed
Php 8.4 Change Affects Test
mime_content_type will recognize files as text/csv rather than text/html.
1 parent 2833ddc commit a51d354

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

tests/PhpSpreadsheetTests/Reader/Csv/NotHtmlTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ public function testHtmlCantRead(): void
3636
fwrite($handle, "{$row[0]},{$row[1]},{$row[2]}\n");
3737
}
3838
fclose($handle);
39-
self::assertSame('text/html', mime_content_type($filename));
39+
// Php8.3- identify file as text/html.
40+
// Php8.4+ identify file as text/csv, and this type of change
41+
// has been known to be retrofitted to prior versions.
42+
$mime = mime_content_type($filename);
43+
if ($mime !== 'text/csv') {
44+
self::assertSame('text/html', $mime);
45+
}
4046
self::assertSame('Csv', IOFactory::identify($filename));
4147
$reader = new CsvReader();
4248
$spreadsheet = $reader->load($filename);
@@ -60,7 +66,13 @@ public function testHtmlCanRead(): void
6066
fwrite($handle, "{$row[0]},{$row[1]},{$row[2]}\n");
6167
}
6268
fclose($handle);
63-
self::assertSame('text/html', mime_content_type($filename));
69+
// Php8.3- identify file as text/html.
70+
// Php8.4+ identify file as text/csv, and this type of change
71+
// has been known to be retrofitted to prior versions.
72+
$mime = mime_content_type($filename);
73+
if ($mime !== 'text/csv') {
74+
self::assertSame('text/html', $mime);
75+
}
6476
self::assertSame('Html', IOFactory::identify($filename));
6577
$reader = new CsvReader();
6678
$spreadsheet = $reader->load($filename);

0 commit comments

Comments
 (0)