Proper mime type detection for XLSX files
Heuristics to detect proper mime type for XLSX files expect to see certain files at the beginning of the XLSX archive. The order in which the XML files are added therefore matters. Specifically, "[Content_Types].xml" should be added first, followed by the files located in the "xl" folder (at least 1 file).
This commit is contained in:
1 parent
05a9a1b60a
commit
728dd3b399
2 files changed
+45
-1
No files matched your search
@@ -385,6 +385,21 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertInlineDataWasWrittenToSheet($fileName, 1, 'control's _x0015_ "character"');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testGeneratedFileShouldHaveTheCorrectMimeType()
|
||||
{
|
||||
$fileName = 'test_mime_type.xlsx';
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
$dataRows = [['foo']];
|
||||
|
||||
$this->writeToXLSXFile($dataRows, $fileName);
|
||||
|
||||
$finfo = new \finfo(FILEINFO_MIME_TYPE);
|
||||
$this->assertEquals('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $finfo->file($resourcePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $allRows
|
||||
* @param string $fileName
|
||||
|
||||
Reference in new issue
Block a user