Add helper functions to create specific readers and writers
Removed the `ReaderEntityFactory::createReader(Type)` method and replaced it by 3 methods: - `ReaderEntityFactory::createCSVReader()` - `ReaderEntityFactory::createXLSXReader()` - `ReaderEntityFactory::createODSReader()` This has the advantage of enabling autocomplete in the IDE, as the return type is no longer the interface but the concrete type. Since readers may expose different options, this is pretty useful. Similarly, removed the `WriterEntityFactory::createWriter(Type)` method and replaced it by 3 methods: - `WriterEntityFactory::createCSVWriter()` - `WriterEntityFactory::createXLSXWriter()` - `WriterEntityFactory::createODSWriter()` Since this is a breaking change, I also updated the Upgrade guide. Finally, the doc is up to date too.
This commit is contained in:
1 parent
6104d41857
commit
40ee386edd
30 files changed
+235
-275
No files matched your search
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Box\Spout\Writer\CSV;
|
||||
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\TestUsingResource;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -38,7 +37,7 @@ class WriterPerfTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::CSV);
|
||||
$writer = WriterEntityFactory::createCSVWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
for ($i = 1; $i <= $numRows; $i++) {
|
||||
|
||||
@@ -6,7 +6,6 @@ use Box\Spout\Common\Entity\Row;
|
||||
use Box\Spout\Common\Exception\InvalidArgumentException;
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Common\Helper\EncodingHelper;
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\TestUsingResource;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||
@@ -32,7 +31,7 @@ class WriterTest extends TestCase
|
||||
$this->createUnwritableFolderIfNeeded();
|
||||
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::CSV);
|
||||
$writer = WriterEntityFactory::createCSVWriter();
|
||||
@$writer->openToFile($filePath);
|
||||
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
||||
$writer->close();
|
||||
@@ -45,7 +44,7 @@ class WriterTest extends TestCase
|
||||
{
|
||||
$this->expectException(WriterNotOpenedException::class);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::CSV);
|
||||
$writer = WriterEntityFactory::createCSVWriter();
|
||||
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
||||
$writer->close();
|
||||
}
|
||||
@@ -57,7 +56,7 @@ class WriterTest extends TestCase
|
||||
{
|
||||
$this->expectException(WriterNotOpenedException::class);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::CSV);
|
||||
$writer = WriterEntityFactory::createCSVWriter();
|
||||
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
||||
$writer->close();
|
||||
}
|
||||
@@ -69,7 +68,7 @@ class WriterTest extends TestCase
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::CSV);
|
||||
$writer = WriterEntityFactory::createCSVWriter();
|
||||
$writer->addRows([['csv--11', 'csv--12']]);
|
||||
$writer->close();
|
||||
}
|
||||
@@ -83,7 +82,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::CSV);
|
||||
$writer = WriterEntityFactory::createCSVWriter();
|
||||
$writer->close(); // This call should not cause any error
|
||||
|
||||
$writer->openToFile($resourcePath);
|
||||
@@ -201,8 +200,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\CSV\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::CSV);
|
||||
$writer = WriterEntityFactory::createCSVWriter();
|
||||
$writer->setFieldDelimiter($fieldDelimiter);
|
||||
$writer->setFieldEnclosure($fieldEnclosure);
|
||||
$writer->setShouldAddBOM($shouldAddBOM);
|
||||
|
||||
@@ -60,7 +60,7 @@ class WriterFactoryTest extends TestCase
|
||||
{
|
||||
$this->expectException(UnsupportedTypeException::class);
|
||||
|
||||
WriterFactory::create('unsupportedType');
|
||||
WriterFactory::createFromType('unsupportedType');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Box\Spout\Writer\ODS;
|
||||
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\TestUsingResource;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use Box\Spout\Writer\Common\Entity\Sheet;
|
||||
@@ -65,8 +64,7 @@ class SheetTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
$customSheetName = 'Sheet name';
|
||||
@@ -104,8 +102,7 @@ class SheetTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
$sheet = $writer->getCurrentSheet();
|
||||
@@ -124,8 +121,7 @@ class SheetTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
$writer->addRow($this->createRowFromValues(['ods--sheet1--11', 'ods--sheet1--12']));
|
||||
@@ -146,8 +142,7 @@ class SheetTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
$sheet = $writer->getCurrentSheet();
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Box\Spout\Writer\ODS;
|
||||
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\TestUsingResource;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -38,8 +37,7 @@ class WriterPerfTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->setShouldCreateNewSheetsAutomatically(true);
|
||||
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
@@ -6,7 +6,6 @@ use Box\Spout\Common\Entity\Row;
|
||||
use Box\Spout\Common\Exception\InvalidArgumentException;
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Common\Exception\SpoutException;
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\Reader\Wrapper\XMLReader;
|
||||
use Box\Spout\TestUsingResource;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
@@ -34,7 +33,7 @@ class WriterTest extends TestCase
|
||||
$this->createUnwritableFolderIfNeeded();
|
||||
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
@$writer->openToFile($filePath);
|
||||
}
|
||||
|
||||
@@ -45,7 +44,7 @@ class WriterTest extends TestCase
|
||||
{
|
||||
$this->expectException(WriterNotOpenedException::class);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->addRow($this->createRowFromValues(['ods--11', 'ods--12']));
|
||||
}
|
||||
|
||||
@@ -56,7 +55,7 @@ class WriterTest extends TestCase
|
||||
{
|
||||
$this->expectException(WriterNotOpenedException::class);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->addRows([$this->createRowFromValues(['ods--11', 'ods--12'])]);
|
||||
}
|
||||
|
||||
@@ -70,8 +69,7 @@ class WriterTest extends TestCase
|
||||
$fileName = 'file_that_wont_be_written.ods';
|
||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->openToFile($filePath);
|
||||
|
||||
$writer->setTempFolder('');
|
||||
@@ -87,8 +85,7 @@ class WriterTest extends TestCase
|
||||
$fileName = 'file_that_wont_be_written.ods';
|
||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->openToFile($filePath);
|
||||
|
||||
$writer->setShouldCreateNewSheetsAutomatically(true);
|
||||
@@ -126,8 +123,7 @@ class WriterTest extends TestCase
|
||||
$this->recreateTempFolder();
|
||||
$tempFolderPath = $this->getTempFolderPath();
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->setTempFolder($tempFolderPath);
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
@@ -151,8 +147,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
$writer->addNewSheetAndMakeItCurrent();
|
||||
$writer->close();
|
||||
@@ -171,8 +166,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
$writer->addNewSheetAndMakeItCurrent();
|
||||
@@ -195,7 +189,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->close(); // This call should not cause any error
|
||||
|
||||
$writer->openToFile($resourcePath);
|
||||
@@ -349,8 +343,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
$writer->addRows($dataRowsSheet1);
|
||||
@@ -485,8 +478,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
||||
|
||||
$writer->openToFile($resourcePath);
|
||||
@@ -508,8 +500,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
||||
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
@@ -6,7 +6,6 @@ use Box\Spout\Common\Entity\Row;
|
||||
use Box\Spout\Common\Entity\Style\Border;
|
||||
use Box\Spout\Common\Entity\Style\Color;
|
||||
use Box\Spout\Common\Entity\Style\Style;
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\Reader\Wrapper\XMLReader;
|
||||
use Box\Spout\TestUsingResource;
|
||||
use Box\Spout\Writer\Common\Creator\Style\BorderBuilder;
|
||||
@@ -42,7 +41,7 @@ class WriterWithStyleTest extends TestCase
|
||||
{
|
||||
$this->expectException(WriterNotOpenedException::class);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->addRow($this->createStyledRowFromValues(['ods--11', 'ods--12'], $this->defaultStyle));
|
||||
}
|
||||
|
||||
@@ -53,7 +52,7 @@ class WriterWithStyleTest extends TestCase
|
||||
{
|
||||
$this->expectException(WriterNotOpenedException::class);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->addRow($this->createStyledRowFromValues(['ods--11', 'ods--12'], $this->defaultStyle));
|
||||
}
|
||||
|
||||
@@ -346,8 +345,7 @@ class WriterWithStyleTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
|
||||
$writer->openToFile($resourcePath);
|
||||
$writer->addRows($allRows);
|
||||
@@ -367,8 +365,7 @@ class WriterWithStyleTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||
$writer = WriterEntityFactory::createODSWriter();
|
||||
$writer->setDefaultRowStyle($defaultStyle);
|
||||
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Box\Spout\Writer\XLSX;
|
||||
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\TestUsingResource;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use Box\Spout\Writer\Common\Entity\Sheet;
|
||||
@@ -65,8 +64,7 @@ class SheetTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
$customSheetName = 'Sheet name';
|
||||
@@ -104,8 +102,7 @@ class SheetTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
$sheet = $writer->getCurrentSheet();
|
||||
@@ -126,8 +123,7 @@ class SheetTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
$writer->addRow($this->createRowFromValues(['xlsx--sheet1--11', 'xlsx--sheet1--12']));
|
||||
@@ -148,8 +144,7 @@ class SheetTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
$sheet = $writer->getCurrentSheet();
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Box\Spout\Writer\XLSX;
|
||||
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\TestUsingResource;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -52,8 +51,7 @@ class WriterPerfTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->setShouldUseInlineStrings($shouldUseInlineStrings);
|
||||
$writer->setShouldCreateNewSheetsAutomatically(true);
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ use Box\Spout\Common\Entity\Row;
|
||||
use Box\Spout\Common\Exception\InvalidArgumentException;
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Common\Exception\SpoutException;
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\TestUsingResource;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use Box\Spout\Writer\Exception\WriterAlreadyOpenedException;
|
||||
@@ -34,7 +33,7 @@ class WriterTest extends TestCase
|
||||
$this->createUnwritableFolderIfNeeded();
|
||||
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
@$writer->openToFile($filePath);
|
||||
}
|
||||
|
||||
@@ -45,7 +44,7 @@ class WriterTest extends TestCase
|
||||
{
|
||||
$this->expectException(WriterNotOpenedException::class);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->addRow($this->createRowFromValues(['xlsx--11', 'xlsx--12']));
|
||||
}
|
||||
|
||||
@@ -56,7 +55,7 @@ class WriterTest extends TestCase
|
||||
{
|
||||
$this->expectException(WriterNotOpenedException::class);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->addRows($this->createRowsFromValues([['xlsx--11', 'xlsx--12']]));
|
||||
}
|
||||
|
||||
@@ -70,8 +69,7 @@ class WriterTest extends TestCase
|
||||
$fileName = 'file_that_wont_be_written.xlsx';
|
||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile($filePath);
|
||||
|
||||
$writer->setTempFolder('');
|
||||
@@ -87,8 +85,7 @@ class WriterTest extends TestCase
|
||||
$fileName = 'file_that_wont_be_written.xlsx';
|
||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile($filePath);
|
||||
|
||||
$writer->setShouldUseInlineStrings(true);
|
||||
@@ -104,8 +101,7 @@ class WriterTest extends TestCase
|
||||
$fileName = 'file_that_wont_be_written.xlsx';
|
||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile($filePath);
|
||||
|
||||
$writer->setShouldCreateNewSheetsAutomatically(true);
|
||||
@@ -158,8 +154,7 @@ class WriterTest extends TestCase
|
||||
$this->recreateTempFolder();
|
||||
$tempFolderPath = $this->getTempFolderPath();
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->setTempFolder($tempFolderPath);
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
@@ -183,8 +178,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
$writer->addNewSheetAndMakeItCurrent();
|
||||
$writer->close();
|
||||
@@ -203,8 +197,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
$writer->addNewSheetAndMakeItCurrent();
|
||||
@@ -227,7 +220,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->close(); // This call should not cause any error
|
||||
|
||||
$writer->openToFile($resourcePath);
|
||||
@@ -404,8 +397,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->setShouldUseInlineStrings(true);
|
||||
|
||||
$writer->openToFile($resourcePath);
|
||||
@@ -544,8 +536,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->setShouldUseInlineStrings($shouldUseInlineStrings);
|
||||
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
||||
|
||||
@@ -569,8 +560,7 @@ class WriterTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->setShouldUseInlineStrings($shouldUseInlineStrings);
|
||||
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
||||
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
|
||||
namespace Box\Spout\Writer\XLSX;
|
||||
|
||||
use Box\Spout\Common\Entity\Cell;
|
||||
use Box\Spout\Common\Entity\Row;
|
||||
use Box\Spout\Common\Entity\Style\Border;
|
||||
use Box\Spout\Common\Entity\Style\Color;
|
||||
use Box\Spout\Common\Entity\Style\Style;
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\Reader\Wrapper\XMLReader;
|
||||
use Box\Spout\TestUsingResource;
|
||||
use Box\Spout\Writer\Common\Creator\Style\BorderBuilder;
|
||||
@@ -45,7 +43,7 @@ class WriterWithStyleTest extends TestCase
|
||||
{
|
||||
$this->expectException(WriterNotOpenedException::class);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->addRow($this->createStyledRowFromValues(['xlsx--11', 'xlsx--12'], $this->defaultStyle));
|
||||
}
|
||||
|
||||
@@ -56,7 +54,7 @@ class WriterWithStyleTest extends TestCase
|
||||
{
|
||||
$this->expectException(WriterNotOpenedException::class);
|
||||
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->addRow($this->createStyledRowFromValues(['xlsx--11', 'xlsx--12'], $this->defaultStyle));
|
||||
}
|
||||
|
||||
@@ -518,8 +516,7 @@ class WriterWithStyleTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->setShouldUseInlineStrings(true);
|
||||
|
||||
$writer->openToFile($resourcePath);
|
||||
@@ -540,8 +537,7 @@ class WriterWithStyleTest extends TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->setShouldUseInlineStrings(true);
|
||||
$writer->setDefaultRowStyle($defaultStyle);
|
||||
|
||||
|
||||
Reference in new issue
Block a user