Refactor writers for better DI (#427)
This commit is a big refactor that improves the code organization. It focuses on how dependencies are injected into the different classes. This is now done via some factories. Also, the code is now built around entities (data model that only exposes getters and setters), managers (used to manage an entity) and helpers (used by the managers to perform some specific tasks). The refactoring is not fully complete, as some dependencies are still hidden...
This commit is contained in:
1 parent
a366d0d0af
commit
bc17311f5f
37 files changed
+1529
-1031
No files matched your search
@@ -62,6 +62,7 @@ class SheetTest extends \PHPUnit_Framework_TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterFactory::create(Type::ODS);
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
@@ -85,6 +86,7 @@ class SheetTest extends \PHPUnit_Framework_TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterFactory::create(Type::ODS);
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
|
||||
@@ -155,6 +155,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var Writer $writer */
|
||||
$writer = WriterFactory::create(Type::ODS);
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
@@ -376,7 +377,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
];
|
||||
|
||||
// set the maxRowsPerSheet limit to 2
|
||||
\ReflectionHelper::setStaticValue('\Box\Spout\Writer\ODS\Internal\Workbook', 'maxRowsPerWorksheet', 2);
|
||||
\ReflectionHelper::setStaticValue('\Box\Spout\Writer\ODS\Manager\WorkbookManager', 'maxRowsPerWorksheet', 2);
|
||||
|
||||
$writer = $this->writeToODSFile($dataRows, $fileName, $shouldCreateSheetsAutomatically = true);
|
||||
$this->assertEquals(2, count($writer->getSheets()), '2 sheets should have been created.');
|
||||
@@ -400,7 +401,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
];
|
||||
|
||||
// set the maxRowsPerSheet limit to 2
|
||||
\ReflectionHelper::setStaticValue('\Box\Spout\Writer\ODS\Internal\Workbook', 'maxRowsPerWorksheet', 2);
|
||||
\ReflectionHelper::setStaticValue('\Box\Spout\Writer\ODS\Manager\WorkbookManager', 'maxRowsPerWorksheet', 2);
|
||||
|
||||
$writer = $this->writeToODSFile($dataRows, $fileName, $shouldCreateSheetsAutomatically = false);
|
||||
$this->assertEquals(1, count($writer->getSheets()), 'Only 1 sheet should have been created.');
|
||||
@@ -500,7 +501,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
foreach ($dataRows as $dataRow) {
|
||||
/** @var Cell $cell */
|
||||
foreach ($dataRow as $cell) {
|
||||
$this->assertValueWasWritten($fileName, (string)$cell->getValue(), '', true);
|
||||
$this->assertValueWasWritten($fileName, (string)$cell->getValue(), '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user