Merge branch 'master' into custom-column-widths
# Conflicts: # src/Spout/Writer/ODS/Manager/WorksheetManager.php # src/Spout/Writer/XLSX/Manager/WorksheetManager.php
This commit is contained in:
commit
615c07649c
40 files changed
+323
-105
No files matched your search
@@ -122,6 +122,6 @@ class RowTest extends \PHPUnit\Framework\TestCase
|
||||
->setStyle($this->getStyleMock())
|
||||
->setCells([]);
|
||||
|
||||
$this->assertInternalType('object', $row);
|
||||
$this->assertInstanceOf(Row::class, $row);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class FileSystemHelperTest extends TestCase
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp() : void
|
||||
{
|
||||
$baseFolder = \sys_get_temp_dir();
|
||||
$this->fileSystemHelper = new FileSystemHelper($baseFolder);
|
||||
|
||||
@@ -14,7 +14,7 @@ class OptionsManagerTest extends TestCase
|
||||
*/
|
||||
protected $optionsManager;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->optionsManager = new class() extends OptionsManagerAbstract {
|
||||
protected function getSupportedOptions()
|
||||
|
||||
@@ -295,6 +295,10 @@ class ReaderTest extends TestCase
|
||||
*/
|
||||
public function testReadShouldBeProtectedAgainstBillionLaughsAttack()
|
||||
{
|
||||
if (function_exists('xdebug_code_coverage_started') && xdebug_code_coverage_started()) {
|
||||
$this->markTestSkipped('test not compatible with code coverage');
|
||||
}
|
||||
|
||||
$startTime = microtime(true);
|
||||
$fileName = 'attack_billion_laughs.ods';
|
||||
|
||||
@@ -318,6 +322,10 @@ class ReaderTest extends TestCase
|
||||
*/
|
||||
public function testReadShouldBeProtectedAgainstQuadraticBlowupAttack()
|
||||
{
|
||||
if (function_exists('xdebug_code_coverage_started') && xdebug_code_coverage_started()) {
|
||||
$this->markTestSkipped('test not compatible with code coverage');
|
||||
}
|
||||
|
||||
$startTime = microtime(true);
|
||||
|
||||
$fileName = 'attack_quadratic_blowup.ods';
|
||||
|
||||
@@ -25,7 +25,7 @@ class SharedStringsManagerTest extends TestCase
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp() : void
|
||||
{
|
||||
$this->sharedStringsManager = null;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class SharedStringsManagerTest extends TestCase
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown()
|
||||
public function tearDown() : void
|
||||
{
|
||||
if ($this->sharedStringsManager !== null) {
|
||||
$this->sharedStringsManager->cleanup();
|
||||
|
||||
@@ -539,6 +539,10 @@ class ReaderTest extends TestCase
|
||||
*/
|
||||
public function testReadShouldBeProtectedAgainstQuadraticBlowupAttack()
|
||||
{
|
||||
if (function_exists('xdebug_code_coverage_started') && xdebug_code_coverage_started()) {
|
||||
$this->markTestSkipped('test not compatible with code coverage');
|
||||
}
|
||||
|
||||
$startTime = microtime(true);
|
||||
|
||||
$this->getAllRowsForFile('attack_quadratic_blowup.xlsx');
|
||||
|
||||
@@ -61,7 +61,7 @@ class WriterPerfTest extends TestCase
|
||||
*/
|
||||
private function getNumWrittenRows($resourcePath)
|
||||
{
|
||||
$lineCountResult = `wc -l $resourcePath`;
|
||||
$lineCountResult = shell_exec("wc -l $resourcePath");
|
||||
|
||||
return (int) $lineCountResult;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ class WriterTest extends TestCase
|
||||
]);
|
||||
$writtenContent = $this->writeToCsvFileAndReturnWrittenContent($allRows, 'csv_with_utf8_bom.csv');
|
||||
|
||||
$this->assertContains(EncodingHelper::BOM_UTF8, $writtenContent, 'The CSV file should contain a UTF-8 BOM');
|
||||
$this->assertStringStartsWith(EncodingHelper::BOM_UTF8, $writtenContent, 'The CSV file should contain a UTF-8 BOM');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ class WriterTest extends TestCase
|
||||
]);
|
||||
$writtenContent = $this->writeToCsvFileAndReturnWrittenContent($allRows, 'csv_no_bom.csv', ',', '"', false);
|
||||
|
||||
$this->assertNotContains(EncodingHelper::BOM_UTF8, $writtenContent, 'The CSV file should not contain a UTF-8 BOM');
|
||||
$this->assertStringNotContainsString(EncodingHelper::BOM_UTF8, $writtenContent, 'The CSV file should not contain a UTF-8 BOM');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@ class SheetTest extends TestCase
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp() : void
|
||||
{
|
||||
$this->sheetManager = new SheetManager(new StringHelper());
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class StyleManagerTest extends TestCase
|
||||
/**
|
||||
* @return StyleManager
|
||||
*/
|
||||
private function getStyleManager()
|
||||
private function getStyleManager() : StyleManager
|
||||
{
|
||||
$style = (new StyleBuilder())->build();
|
||||
$styleRegistry = new StyleRegistry($style);
|
||||
@@ -22,31 +22,37 @@ class StyleManagerTest extends TestCase
|
||||
return new StyleManager($styleRegistry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testApplyExtraStylesIfNeededShouldApplyWrapTextIfCellContainsNewLine()
|
||||
public function testApplyExtraStylesIfNeededShouldApplyWrapTextIfCellContainsNewLine() : void
|
||||
{
|
||||
$style = (new StyleBuilder())->build();
|
||||
$this->assertFalse($style->shouldWrapText());
|
||||
|
||||
$styleManager = $this->getStyleManager();
|
||||
$updatedStyle = $styleManager->applyExtraStylesIfNeeded(new Cell("multi\nlines", $style));
|
||||
$possiblyUpdatedStyle = $styleManager->applyExtraStylesIfNeeded(new Cell("multi\nlines", $style));
|
||||
|
||||
$this->assertTrue($updatedStyle->shouldWrapText());
|
||||
$this->assertTrue($possiblyUpdatedStyle->isUpdated());
|
||||
$this->assertTrue($possiblyUpdatedStyle->getStyle()->shouldWrapText());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testApplyExtraStylesIfNeededShouldDoNothingIfWrapTextAlreadyApplied()
|
||||
public function testApplyExtraStylesIfNeededShouldReturnNullIfWrapTextNotNeeded() : void
|
||||
{
|
||||
$style = (new StyleBuilder())->build();
|
||||
$this->assertFalse($style->shouldWrapText());
|
||||
|
||||
$styleManager = $this->getStyleManager();
|
||||
$possiblyUpdatedStyle = $styleManager->applyExtraStylesIfNeeded(new Cell('oneline', $style));
|
||||
|
||||
$this->assertFalse($possiblyUpdatedStyle->isUpdated());
|
||||
}
|
||||
|
||||
public function testApplyExtraStylesIfNeededShouldReturnNullIfWrapTextAlreadyApplied() : void
|
||||
{
|
||||
$style = (new StyleBuilder())->setShouldWrapText()->build();
|
||||
$this->assertTrue($style->shouldWrapText());
|
||||
|
||||
$styleManager = $this->getStyleManager();
|
||||
$updatedStyle = $styleManager->applyExtraStylesIfNeeded(new Cell("multi\nlines", $style));
|
||||
$possiblyUpdatedStyle = $styleManager->applyExtraStylesIfNeeded(new Cell("multi\nlines", $style));
|
||||
|
||||
$this->assertTrue($updatedStyle->shouldWrapText());
|
||||
$this->assertFalse($possiblyUpdatedStyle->isUpdated());
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ class StyleMergerTest extends TestCase
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp() : void
|
||||
{
|
||||
$this->styleMerger = new StyleMerger();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class StyleRegistryTest extends TestCase
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp() : void
|
||||
{
|
||||
$this->defaultStyle = (new StyleBuilder())->build();
|
||||
$this->styleRegistry = new StyleRegistry($this->defaultStyle);
|
||||
|
||||
@@ -90,7 +90,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"');
|
||||
}
|
||||
|
||||
public function testThrowsIfWorkbookIsNotInitialized()
|
||||
@@ -285,6 +285,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);
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ class WriterPerfTest extends TestCase
|
||||
copy($pathToContentXmlFile, $tmpFile);
|
||||
|
||||
// Get the last 200 characters
|
||||
$lastCharacters = `tail -c 200 $tmpFile`;
|
||||
$lastCharacters = shell_exec("tail -c 200 $tmpFile");
|
||||
|
||||
// remove the temporary file
|
||||
unlink($tmpFile);
|
||||
|
||||
@@ -547,7 +547,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -562,7 +562,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -577,7 +577,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();
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class SheetTest extends TestCase
|
||||
$pathToWorkbookFile = $resourcePath . '#xl/workbook.xml';
|
||||
$xmlContents = file_get_contents('zip://' . $pathToWorkbookFile);
|
||||
|
||||
$this->assertContains(' state="hidden"', $xmlContents, 'The sheet visibility should have been changed to "hidden"');
|
||||
$this->assertStringContainsString(' state="hidden"', $xmlContents, 'The sheet visibility should have been changed to "hidden"');
|
||||
}
|
||||
|
||||
public function testThrowsIfWorkbookIsNotInitialized()
|
||||
@@ -299,6 +299,6 @@ class SheetTest extends TestCase
|
||||
$pathToWorkbookFile = $resourcePath . '#xl/workbook.xml';
|
||||
$xmlContents = file_get_contents('zip://' . $pathToWorkbookFile);
|
||||
|
||||
$this->assertContains("<sheet name=\"$expectedName\"", $xmlContents, $message);
|
||||
$this->assertStringContainsString("<sheet name=\"$expectedName\"", $xmlContents, $message);
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,7 @@ class WriterPerfTest extends TestCase
|
||||
copy($filePath, $tmpFile);
|
||||
|
||||
// Get the last 200 characters
|
||||
$lastCharacters = `tail -c $numCharacters $tmpFile`;
|
||||
$lastCharacters = shell_exec("tail -c $numCharacters $tmpFile");
|
||||
|
||||
// remove the temporary file
|
||||
unlink($tmpFile);
|
||||
|
||||
@@ -608,7 +608,7 @@ class WriterTest extends TestCase
|
||||
$pathToSheetFile = $resourcePath . '#xl/worksheets/sheet' . $sheetIndex . '.xml';
|
||||
$xmlContents = file_get_contents('zip://' . $pathToSheetFile);
|
||||
|
||||
$this->assertContains((string) $inlineData, $xmlContents, $message);
|
||||
$this->assertStringContainsString((string) $inlineData, $xmlContents, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -624,7 +624,7 @@ class WriterTest extends TestCase
|
||||
$pathToSheetFile = $resourcePath . '#xl/worksheets/sheet' . $sheetIndex . '.xml';
|
||||
$xmlContents = file_get_contents('zip://' . $pathToSheetFile);
|
||||
|
||||
$this->assertNotContains((string) $inlineData, $xmlContents, $message);
|
||||
$this->assertStringNotContainsString((string) $inlineData, $xmlContents, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -639,6 +639,6 @@ class WriterTest extends TestCase
|
||||
$pathToSharedStringsFile = $resourcePath . '#xl/sharedStrings.xml';
|
||||
$xmlContents = file_get_contents('zip://' . $pathToSharedStringsFile);
|
||||
|
||||
$this->assertContains($sharedString, $xmlContents, $message);
|
||||
$this->assertStringContainsString($sharedString, $xmlContents, $message);
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class WriterWithStyleTest extends TestCase
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp() : void
|
||||
{
|
||||
$this->defaultStyle = (new StyleBuilder())->build();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user