tempFile !== '') { unlink($this->tempFile); $this->tempFile = ''; } } public function testHtmlCantRead(): void { // This test has a file which IOFactory will identify as Csv. // So file can be read using either Csv Reader or IOFactory. $this->tempFile = $filename = File::temporaryFilename(); $cells = [ ['1', 'example', '3'], ['4', '5', '6'], ]; $handle = fopen($filename, 'wb'); self::assertNotFalse($handle); foreach ($cells as $row) { fwrite($handle, "{$row[0]},{$row[1]},{$row[2]}\n"); } fclose($handle); // Php8.3- identify file as text/html. // Php8.4+ identify file as text/csv, and this type of change // has been known to be retrofitted to prior versions. $mime = mime_content_type($filename); if ($mime !== 'text/csv') { self::assertSame('text/html', $mime); } self::assertSame('Csv', IOFactory::identify($filename)); $reader = new CsvReader(); $spreadsheet = $reader->load($filename); $sheet = $spreadsheet->getActiveSheet(); self::assertSame($cells, $sheet->toArray()); $spreadsheet->disconnectWorksheets(); } public function testHtmlCanRead(): void { // This test has a file which IOFactory will identify as Html. // So file has to be read using Csv Reader, not IOFactory. $this->tempFile = $filename = File::temporaryFilename(); $cells = [ ['example', '