Merge branch 'master' of github.com:box/spout into add-phpstan

 Conflicts:
	.travis.yml
	CONTRIBUTING.md
	composer.json
	src/Spout/Common/Entity/Cell.php
	tests/Spout/Writer/ODS/WriterTest.php
This commit is contained in:
Antoine Lamirault committed 2021-09-18 18:14:45 +02:00
commit 540667870a
49 files changed
+529 -152

No files matched your search

+2 -2
View File
@@ -89,7 +89,7 @@ class SheetTest extends TestCase
$pathToContentFile = $resourcePath . '#content.xml';
$xmlContents = file_get_contents('zip://' . $pathToContentFile);
$this->assertContains(' table:display="false"', $xmlContents, 'The sheet visibility should have been changed to "hidden"');
$this->assertStringContainsString(' table:display="false"', $xmlContents, 'The sheet visibility should have been changed to "hidden"');
}
/**
@@ -164,6 +164,6 @@ class SheetTest extends TestCase
$pathToWorkbookFile = $resourcePath . '#content.xml';
$xmlContents = file_get_contents('zip://' . $pathToWorkbookFile);
$this->assertContains("table:name=\"$expectedName\"", $xmlContents, $message);
$this->assertStringContainsString("table:name=\"$expectedName\"", $xmlContents, $message);
}
}
+38 -3
View File
@@ -279,6 +279,41 @@ class WriterTest extends TestCase
$this->assertValueWasWrittenToSheet($fileName, 1, 10.2);
}
/**
* @return void
*/
public function testAddRowShouldSupportFloatValuesInDifferentLocale()
{
$previousLocale = \setlocale(LC_ALL, 0);
try {
// Pick a supported locale whose decimal point is a comma.
// Installed locales differ from one system to another, so we can't pick
// a given locale.
$supportedLocales = explode("\n", shell_exec('locale -a'));
foreach ($supportedLocales as $supportedLocale) {
\setlocale(LC_ALL, $supportedLocale);
if (\localeconv()['decimal_point'] === ',') {
break;
}
}
$this->assertEquals(',', \localeconv()['decimal_point']);
$fileName = 'test_add_row_should_support_float_values_in_different_locale.xlsx';
$dataRows = $this->createRowsFromValues([
[1234.5],
]);
$this->writeToODSFile($dataRows, $fileName);
$this->assertValueWasNotWrittenToSheet($fileName, 1, "1234,5");
$this->assertValueWasWrittenToSheet($fileName, 1, "1234.5");
} finally {
// reset locale
\setlocale(LC_ALL, $previousLocale);
}
}
/**
* @return array<array>
*/
@@ -548,7 +583,7 @@ class WriterTest extends TestCase
$pathToContentFile = $resourcePath . '#content.xml';
$xmlContents = file_get_contents('zip://' . $pathToContentFile);
$this->assertContains($value, $xmlContents, $message);
$this->assertStringContainsString($value, $xmlContents, $message);
}
/**
@@ -563,7 +598,7 @@ class WriterTest extends TestCase
$sheetXmlAsString = $this->getSheetXmlNodeAsString($fileName, $sheetIndex);
$valueAsXmlString = "<text:p>$value</text:p>";
$this->assertContains($valueAsXmlString, $sheetXmlAsString, $message);
$this->assertStringContainsString($valueAsXmlString, $sheetXmlAsString, $message);
}
/**
@@ -578,7 +613,7 @@ class WriterTest extends TestCase
$sheetXmlAsString = $this->getSheetXmlNodeAsString($fileName, $sheetIndex);
$valueAsXmlString = "<text:p>$value</text:p>";
$this->assertNotContains($valueAsXmlString, $sheetXmlAsString, $message);
$this->assertStringNotContainsString($valueAsXmlString, $sheetXmlAsString, $message);
}
/**
@@ -30,7 +30,7 @@ class WriterWithStyleTest extends TestCase
/**
* @return void
*/
public function setUp()
public function setUp() : void
{
$this->defaultStyle = (new StyleBuilder())->build();
}