Consolidate external EntityFactory
All entities will now be created through a single factory (including the Writers). Also, added a EntityFactory::createRowFromArray() to make it easier to create rows
This commit is contained in:
1 parent
2d2151ac8d
commit
3d0f108b1d
12 files changed
+201
-170
No files matched your search
@@ -7,10 +7,10 @@ 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\EntityFactory;
|
||||
use Box\Spout\Writer\Common\Entity\Row;
|
||||
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||
use Box\Spout\Writer\RowCreationHelper;
|
||||
use Box\Spout\Writer\WriterFactory;
|
||||
|
||||
/**
|
||||
* Class WriterTest
|
||||
@@ -31,7 +31,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$this->createUnwritableFolderIfNeeded();
|
||||
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
||||
|
||||
$writer = WriterFactory::create(Type::CSV);
|
||||
$writer = EntityFactory::createWriter(Type::CSV);
|
||||
@$writer->openToFile($filePath);
|
||||
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
||||
$writer->close();
|
||||
@@ -44,7 +44,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->expectException(WriterNotOpenedException::class);
|
||||
|
||||
$writer = WriterFactory::create(Type::CSV);
|
||||
$writer = EntityFactory::createWriter(Type::CSV);
|
||||
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
||||
$writer->close();
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->expectException(WriterNotOpenedException::class);
|
||||
|
||||
$writer = WriterFactory::create(Type::CSV);
|
||||
$writer = EntityFactory::createWriter(Type::CSV);
|
||||
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
||||
$writer->close();
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
$writer = WriterFactory::create(Type::CSV);
|
||||
$writer = EntityFactory::createWriter(Type::CSV);
|
||||
$writer->addRows([['csv--11', 'csv--12']]);
|
||||
$writer->close();
|
||||
}
|
||||
@@ -82,7 +82,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
$writer = WriterFactory::create(Type::CSV);
|
||||
$writer = EntityFactory::createWriter(Type::CSV);
|
||||
$writer->close(); // This call should not cause any error
|
||||
|
||||
$writer->openToFile($resourcePath);
|
||||
@@ -189,7 +189,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\CSV\Writer $writer */
|
||||
$writer = WriterFactory::create(Type::CSV);
|
||||
$writer = EntityFactory::createWriter(Type::CSV);
|
||||
$writer->setFieldDelimiter($fieldDelimiter);
|
||||
$writer->setFieldEnclosure($fieldEnclosure);
|
||||
$writer->setShouldAddBOM($shouldAddBOM);
|
||||
|
||||
Reference in new issue
Block a user