From 9882bf094668e3530b6d2730bd31807e3e607973 Mon Sep 17 00:00:00 2001 From: Adrien Loison Date: Fri, 12 Nov 2021 15:14:51 +0100 Subject: [PATCH] Fix errors on Windows --- tests/Spout/Reader/CSV/ReaderTest.php | 7 +++++-- tests/Spout/Writer/ODS/WriterTest.php | 4 ++++ tests/Spout/Writer/XLSX/WriterTest.php | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/Spout/Reader/CSV/ReaderTest.php b/tests/Spout/Reader/CSV/ReaderTest.php index 684b045..1d092f0 100644 --- a/tests/Spout/Reader/CSV/ReaderTest.php +++ b/tests/Spout/Reader/CSV/ReaderTest.php @@ -237,7 +237,9 @@ class ReaderTest extends TestCase public function testReadShouldNotTruncateLineBreak() { $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'); + $newLine = PHP_EOL; // to support both Unix and Windows $expectedRows = [ ['A'], [' A '], - ["\n\tA\n\t"], + ["$newLine\tA$newLine\t"], ]; $this->assertEquals($expectedRows, $allRows, 'Cell values should not be trimmed'); diff --git a/tests/Spout/Writer/ODS/WriterTest.php b/tests/Spout/Writer/ODS/WriterTest.php index 790b094..d9295bb 100644 --- a/tests/Spout/Writer/ODS/WriterTest.php +++ b/tests/Spout/Writer/ODS/WriterTest.php @@ -518,6 +518,10 @@ class WriterTest extends TestCase */ 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'; $resourcePath = $this->getGeneratedResourcePath($fileName); $dataRow = ['foo']; diff --git a/tests/Spout/Writer/XLSX/WriterTest.php b/tests/Spout/Writer/XLSX/WriterTest.php index a1cbc2d..2469506 100644 --- a/tests/Spout/Writer/XLSX/WriterTest.php +++ b/tests/Spout/Writer/XLSX/WriterTest.php @@ -575,6 +575,10 @@ class WriterTest extends TestCase */ 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'; $resourcePath = $this->getGeneratedResourcePath($fileName); $dataRows = $this->createRowsFromValues([['foo']]);