Fix errors on Windows

This commit is contained in:
Adrien Loison 2021-11-12 15:14:51 +01:00
parent 75c06807af
commit 9882bf0946
3 changed files with 13 additions and 2 deletions

View File

@ -237,7 +237,9 @@ class ReaderTest extends TestCase
public function testReadShouldNotTruncateLineBreak() public function testReadShouldNotTruncateLineBreak()
{ {
$allRows = $this->getAllRowsForFile('csv_with_line_breaks.csv'); $allRows = $this->getAllRowsForFile('csv_with_line_breaks.csv');
$this->assertEquals("This is,\na comma", $allRows[0][0]);
$newLine = PHP_EOL; // to support both Unix and Windows
$this->assertEquals("This is,{$newLine}a comma", $allRows[0][0]);
} }
/** /**
@ -419,10 +421,11 @@ class ReaderTest extends TestCase
{ {
$allRows = $this->getAllRowsForFile('sheet_with_untrimmed_strings.csv'); $allRows = $this->getAllRowsForFile('sheet_with_untrimmed_strings.csv');
$newLine = PHP_EOL; // to support both Unix and Windows
$expectedRows = [ $expectedRows = [
['A'], ['A'],
[' A '], [' A '],
["\n\tA\n\t"], ["$newLine\tA$newLine\t"],
]; ];
$this->assertEquals($expectedRows, $allRows, 'Cell values should not be trimmed'); $this->assertEquals($expectedRows, $allRows, 'Cell values should not be trimmed');

View File

@ -518,6 +518,10 @@ class WriterTest extends TestCase
*/ */
public function testGeneratedFileShouldHaveTheCorrectMimeType() public function testGeneratedFileShouldHaveTheCorrectMimeType()
{ {
if (!function_exists('finfo')) {
$this->markTestSkipped('finfo is not available on this system (possibly running on Windows where the DLL needs to be added explicitly to the php.ini)');
}
$fileName = 'test_mime_type.ods'; $fileName = 'test_mime_type.ods';
$resourcePath = $this->getGeneratedResourcePath($fileName); $resourcePath = $this->getGeneratedResourcePath($fileName);
$dataRow = ['foo']; $dataRow = ['foo'];

View File

@ -575,6 +575,10 @@ class WriterTest extends TestCase
*/ */
public function testGeneratedFileShouldHaveTheCorrectMimeType() public function testGeneratedFileShouldHaveTheCorrectMimeType()
{ {
if (!function_exists('finfo')) {
$this->markTestSkipped('finfo is not available on this system (possibly running on Windows where the DLL needs to be added explicitly to the php.ini)');
}
$fileName = 'test_mime_type.xlsx'; $fileName = 'test_mime_type.xlsx';
$resourcePath = $this->getGeneratedResourcePath($fileName); $resourcePath = $this->getGeneratedResourcePath($fileName);
$dataRows = $this->createRowsFromValues([['foo']]); $dataRows = $this->createRowsFromValues([['foo']]);