make tests pass again

This commit is contained in:
madflow 2017-09-29 14:47:33 +02:00
parent 6971a793ef
commit 2797052c54
12 changed files with 44 additions and 113 deletions

View File

@ -8,7 +8,9 @@ use Box\Spout\Writer\Common\Entity\Sheet;
use Box\Spout\Writer\Common\Entity\Style\Style; use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Entity\Workbook; use Box\Spout\Writer\Common\Entity\Workbook;
use Box\Spout\Writer\Common\Entity\Worksheet; use Box\Spout\Writer\Common\Entity\Worksheet;
use Box\Spout\Writer\Common\Manager\RowManager;
use Box\Spout\Writer\Common\Manager\SheetManager; use Box\Spout\Writer\Common\Manager\SheetManager;
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
/** /**
* Class EntityFactory * Class EntityFactory
@ -49,7 +51,7 @@ class EntityFactory
* @param mixed $cellValue * @param mixed $cellValue
* @return Cell * @return Cell
*/ */
public function createCell($cellValue) public static function createCell($cellValue)
{ {
return new Cell($cellValue); return new Cell($cellValue);
} }
@ -67,9 +69,10 @@ class EntityFactory
* @param Style|null $style * @param Style|null $style
* @return Row * @return Row
*/ */
public function createRow(array $cells, Style $style = null) public static function createRow(array $cells, Style $style = null)
{ {
$rowManager = $this->managerFactory->createRowManager(); $styleMerger = new StyleMerger();
$rowManager = new RowManager($styleMerger);
return new Row($cells, $style, $rowManager); return new Row($cells, $style, $rowManager);
} }
} }

View File

@ -7,17 +7,14 @@ use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Writer\Common\Creator\EntityFactory; use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface; use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface;
use Box\Spout\Writer\Common\Entity\Options; use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Writer\Common\Manager\Style\StyleManagerInterface;
use Box\Spout\Writer\Common\Entity\Row; use Box\Spout\Writer\Common\Entity\Row;
use Box\Spout\Writer\Common\Entity\Sheet; use Box\Spout\Writer\Common\Entity\Sheet;
use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Entity\Workbook; use Box\Spout\Writer\Common\Entity\Workbook;
use Box\Spout\Writer\Common\Entity\Worksheet; use Box\Spout\Writer\Common\Entity\Worksheet;
use Box\Spout\Writer\Common\Helper\FileSystemWithRootFolderHelperInterface; use Box\Spout\Writer\Common\Helper\FileSystemWithRootFolderHelperInterface;
use Box\Spout\Writer\Common\Manager\Style\StyleManagerInterface; use Box\Spout\Writer\Common\Manager\Style\StyleManagerInterface;
use Box\Spout\Writer\Exception\SheetNotFoundException; use Box\Spout\Writer\Exception\SheetNotFoundException;
use Box\Spout\Writer\Exception\WriterException; use Box\Spout\Writer\Exception\WriterException;
use Box\Spout\Writer\Common\Creator\EntityFactory;
/** /**
* Class WorkbookManagerAbstract * Class WorkbookManagerAbstract

View File

@ -4,10 +4,10 @@ namespace Box\Spout\Writer\ODS\Manager;
use Box\Spout\Common\Exception\InvalidArgumentException; use Box\Spout\Common\Exception\InvalidArgumentException;
use Box\Spout\Common\Exception\IOException; use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Helper\Escaper\ODS as ODSEscaper;
use Box\Spout\Common\Helper\StringHelper; use Box\Spout\Common\Helper\StringHelper;
use Box\Spout\Writer\Common\Creator\EntityFactory; use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Entity\Cell; use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Entity\Row; use Box\Spout\Writer\Common\Entity\Row;
use Box\Spout\Writer\Common\Entity\Worksheet; use Box\Spout\Writer\Common\Entity\Worksheet;
use Box\Spout\Writer\Common\Manager\WorksheetManagerInterface; use Box\Spout\Writer\Common\Manager\WorksheetManagerInterface;
@ -25,34 +25,23 @@ class WorksheetManager implements WorksheetManagerInterface
/** @var StringHelper String helper */ /** @var StringHelper String helper */
private $stringHelper; private $stringHelper;
/** @var EntityFactory Factory to create entities */
private $entityFactory;
/** @var StyleManager Manages styles */ /** @var StyleManager Manages styles */
private $styleManager; private $styleManager;
/** /**
* WorksheetManager constructor. * WorksheetManager constructor.
*
* @param \Box\Spout\Common\Helper\Escaper\ODS $stringsEscaper
* @param StyleManager $styleManager * @param StyleManager $styleManager
* @param \Box\Spout\Common\Escaper\ODS $stringsEscaper * @param ODSEscaper $stringsEscaper
* @param StringHelper $stringHelper * @param StringHelper $stringHelper
* @param EntityFactory $entityFactory
*/ */
public function __construct( public function __construct(
StyleManager $styleManager, StyleManager $styleManager,
\Box\Spout\Common\Escaper\ODS $stringsEscaper, ODSEscaper $stringsEscaper,
StringHelper $stringHelper) StringHelper $stringHelper)
{ {
\Box\Spout\Common\Helper\Escaper\ODS $stringsEscaper,
StringHelper $stringHelper,
EntityFactory $entityFactory
) {
$this->stringsEscaper = $stringsEscaper; $this->stringsEscaper = $stringsEscaper;
$this->stringHelper = $stringHelper; $this->stringHelper = $stringHelper;
$this->styleManager = $styleManager; $this->styleManager = $styleManager;
$this->entityFactory = $entityFactory;
} }
/** /**

View File

@ -7,6 +7,7 @@ use Box\Spout\Common\Exception\InvalidArgumentException;
use Box\Spout\Common\Exception\IOException; use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Exception\SpoutException; use Box\Spout\Common\Exception\SpoutException;
use Box\Spout\Common\Helper\GlobalFunctionsHelper; use Box\Spout\Common\Helper\GlobalFunctionsHelper;
use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Entity\Cell; use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Common\Manager\OptionsManagerInterface; use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Writer\Common\Entity\Options; use Box\Spout\Writer\Common\Entity\Options;
@ -63,8 +64,6 @@ abstract class WriterAbstract implements WriterInterface
$this->styleMerger = $styleMerger; $this->styleMerger = $styleMerger;
$this->globalFunctionsHelper = $globalFunctionsHelper; $this->globalFunctionsHelper = $globalFunctionsHelper;
$this->helperFactory = $helperFactory; $this->helperFactory = $helperFactory;
$this->resetRowStyleToDefault();
} }
/** /**
@ -210,7 +209,7 @@ abstract class WriterAbstract implements WriterInterface
*/ */
public function withRow(\Closure $callback) public function withRow(\Closure $callback)
{ {
return $this->addRow($callback(new Row())); return $this->addRow($callback(EntityFactory::createRow([])));
} }
/** /**

View File

@ -2,6 +2,7 @@
namespace Box\Spout\Writer; namespace Box\Spout\Writer;
use Box\Spout\Common\Creator\HelperFactory;
use Box\Spout\Common\Helper\GlobalFunctionsHelper; use Box\Spout\Common\Helper\GlobalFunctionsHelper;
use Box\Spout\Common\Manager\OptionsManagerInterface; use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface; use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface;

View File

@ -17,17 +17,6 @@ class WriterTest extends \PHPUnit_Framework_TestCase
{ {
use TestUsingResource; use TestUsingResource;
/**
* @var EntityFactory
*/
protected $entityFactory;
protected function setUp()
{
$this->entityFactory = new EntityFactory(new ManagerFactory());
parent::setUp();
}
/** /**
* @expectedException \Box\Spout\Common\Exception\IOException * @expectedException \Box\Spout\Common\Exception\IOException
*/ */
@ -39,7 +28,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::CSV); $writer = WriterFactory::create(Type::CSV);
@$writer->openToFile($filePath); @$writer->openToFile($filePath);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('csv--11'), new Cell('csv--11'),
new Cell('csv--12') new Cell('csv--12')
]); ]);
@ -53,7 +42,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
public function testWriteShouldThrowExceptionIfCallAddRowBeforeOpeningWriter() public function testWriteShouldThrowExceptionIfCallAddRowBeforeOpeningWriter()
{ {
$writer = WriterFactory::create(Type::CSV); $writer = WriterFactory::create(Type::CSV);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('csv--11'), new Cell('csv--11'),
new Cell('csv--12') new Cell('csv--12')
]); ]);
@ -67,7 +56,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
public function testWriteShouldThrowExceptionIfCallAddRowsBeforeOpeningWriter() public function testWriteShouldThrowExceptionIfCallAddRowsBeforeOpeningWriter()
{ {
$writer = WriterFactory::create(Type::CSV); $writer = WriterFactory::create(Type::CSV);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('csv--11'), new Cell('csv--11'),
new Cell('csv--12') new Cell('csv--12')
]); ]);
@ -237,7 +226,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$writer->openToFile($resourcePath); $writer->openToFile($resourcePath);
$writer->addRows(array_map(function ($oneRow) { $writer->addRows(array_map(function ($oneRow) {
$row = $this->entityFactory->createRow(array_map(function ($value) { $row = EntityFactory::createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $oneRow)); }, $oneRow));
return $row; return $row;

View File

@ -17,20 +17,6 @@ class SheetTest extends \PHPUnit_Framework_TestCase
{ {
use TestUsingResource; use TestUsingResource;
/**
* @var EntityFactory
*/
protected $entityFactory;
/**
* @return void
*/
public function setUp()
{
$this->entityFactory = new EntityFactory(new ManagerFactory());
}
/** /**
* @return void * @return void
*/ */
@ -108,7 +94,7 @@ class SheetTest extends \PHPUnit_Framework_TestCase
$sheet = $writer->getCurrentSheet(); $sheet = $writer->getCurrentSheet();
$sheet->setName($sheetName); $sheet->setName($sheetName);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('ods--11'), new Cell('ods--11'),
new Cell('ods--12'), new Cell('ods--12'),
]); ]);
@ -129,7 +115,7 @@ class SheetTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::ODS); $writer = WriterFactory::create(Type::ODS);
$writer->openToFile($resourcePath); $writer->openToFile($resourcePath);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('ods--sheet1--11'), new Cell('ods--sheet1--11'),
new Cell('ods--sheet1--12'), new Cell('ods--sheet1--12'),
]); ]);
@ -137,7 +123,7 @@ class SheetTest extends \PHPUnit_Framework_TestCase
$writer->addNewSheetAndMakeItCurrent(); $writer->addNewSheetAndMakeItCurrent();
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('ods--sheet2--11'), new Cell('ods--sheet2--11'),
new Cell('ods--sheet2--12'), new Cell('ods--sheet2--12'),
new Cell('ods--sheet2--13'), new Cell('ods--sheet2--13'),

View File

@ -7,8 +7,6 @@ use Box\Spout\Common\Type;
use Box\Spout\Reader\Wrapper\XMLReader; use Box\Spout\Reader\Wrapper\XMLReader;
use Box\Spout\TestUsingResource; use Box\Spout\TestUsingResource;
use Box\Spout\Writer\Common\Creator\EntityFactory; use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Creator\ManagerFactory;
use Box\Spout\Writer\Common\Helper\ZipHelper;
use Box\Spout\Writer\Common\Entity\Cell; use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\Common\Helper\ZipHelper; use Box\Spout\Writer\Common\Helper\ZipHelper;
use Box\Spout\Writer\WriterFactory; use Box\Spout\Writer\WriterFactory;
@ -30,7 +28,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
*/ */
protected function setUp() protected function setUp()
{ {
$this->entityFactory = new EntityFactory(new ManagerFactory()); $this->entityFactory = new EntityFactory();
parent::setUp(); parent::setUp();
} }

View File

@ -6,13 +6,10 @@ use Box\Spout\Common\Type;
use Box\Spout\Reader\Wrapper\XMLReader; use Box\Spout\Reader\Wrapper\XMLReader;
use Box\Spout\TestUsingResource; use Box\Spout\TestUsingResource;
use Box\Spout\Writer\Common\Creator\EntityFactory; use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Creator\ManagerFactory;
use Box\Spout\Writer\Common\Entity\Cell; use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\ODS\Helper\BorderHelper;
use Box\Spout\Writer\Common\Entity\Style\Border; use Box\Spout\Writer\Common\Entity\Style\Border;
use Box\Spout\Writer\Common\Creator\Style\BorderBuilder; use Box\Spout\Writer\Common\Creator\Style\BorderBuilder;
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder; use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
use Box\Spout\Writer\Common\Entity\Style\Border;
use Box\Spout\Writer\Common\Entity\Style\Color; use Box\Spout\Writer\Common\Entity\Style\Color;
use Box\Spout\Writer\Common\Entity\Style\Style; use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\WriterFactory; use Box\Spout\Writer\WriterFactory;
@ -27,17 +24,11 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
/** @var Style */ /** @var Style */
private $defaultStyle; private $defaultStyle;
/**
* @var EntityFactory
*/
protected $entityFactory;
/** /**
* @return void * @return void
*/ */
public function setUp() public function setUp()
{ {
$this->entityFactory = new EntityFactory(new ManagerFactory());
$this->defaultStyle = (new StyleBuilder())->build(); $this->defaultStyle = (new StyleBuilder())->build();
} }
@ -47,7 +38,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
public function testAddRowWithStyleShouldThrowExceptionIfCallAddRowBeforeOpeningWriter() public function testAddRowWithStyleShouldThrowExceptionIfCallAddRowBeforeOpeningWriter()
{ {
$writer = WriterFactory::create(Type::ODS); $writer = WriterFactory::create(Type::ODS);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('ods--11'), new Cell('ods--11'),
new Cell('ods--12'), new Cell('ods--12'),
], $this->defaultStyle); ], $this->defaultStyle);
@ -60,7 +51,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
public function testAddRowsWithStyleShouldThrowExceptionIfCalledBeforeOpeningWriter() public function testAddRowsWithStyleShouldThrowExceptionIfCalledBeforeOpeningWriter()
{ {
$writer = WriterFactory::create(Type::ODS); $writer = WriterFactory::create(Type::ODS);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('ods--11'), new Cell('ods--11'),
new Cell('ods--12'), new Cell('ods--12'),
], $this->defaultStyle); ], $this->defaultStyle);
@ -97,7 +88,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::ODS); $writer = WriterFactory::create(Type::ODS);
$writer->openToFile($resourcePath); $writer->openToFile($resourcePath);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('ods--11'), new Cell('ods--11'),
new Cell('ods--12'), new Cell('ods--12'),
], $style); ], $style);
@ -124,7 +115,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::ODS); $writer = WriterFactory::create(Type::ODS);
$writer->openToFile($resourcePath); $writer->openToFile($resourcePath);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('ods--11'), new Cell('ods--11'),
new Cell('ods--12'), new Cell('ods--12'),
], $style); ], $style);
@ -365,7 +356,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
public function testSetDefaultRowStyle() public function testSetDefaultRowStyle()
{ {
$fileName = 'test_set_default_row_style.ods'; $fileName = 'test_set_default_row_style.ods';
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('ods--11') new Cell('ods--11')
]); ]);
$dataRows = [$row]; $dataRows = [$row];
@ -389,7 +380,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
{ {
$arrayToRows = function (array $allRows) use ($style) { $arrayToRows = function (array $allRows) use ($style) {
return array_map(function ($oneRow) use ($style) { return array_map(function ($oneRow) use ($style) {
$row = $this->entityFactory->createRow(array_map(function ($value) { $row = EntityFactory::createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $oneRow), $style); }, $oneRow), $style);
return $row; return $row;
@ -452,7 +443,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
for ($i = 0; $i < count($allRows); $i++) { for ($i = 0; $i < count($allRows); $i++) {
$currentRow = $allRows[$i]; $currentRow = $allRows[$i];
$currentStyle = $styles[$i]; $currentStyle = $styles[$i];
$row = $this->entityFactory->createRow(array_map(function ($value) { $row = EntityFactory::createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $currentRow), $currentStyle); }, $currentRow), $currentStyle);
$writer->addRow($row); $writer->addRow($row);

View File

@ -17,19 +17,6 @@ class SheetTest extends \PHPUnit_Framework_TestCase
{ {
use TestUsingResource; use TestUsingResource;
/**
* @var EntityFactory
*/
protected $entityFactory;
/**
* @return void
*/
public function setUp()
{
$this->entityFactory = new EntityFactory(new ManagerFactory());
}
/** /**
* @return void * @return void
*/ */
@ -107,7 +94,7 @@ class SheetTest extends \PHPUnit_Framework_TestCase
$sheet = $writer->getCurrentSheet(); $sheet = $writer->getCurrentSheet();
$sheet->setName($sheetName); $sheet->setName($sheetName);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('xlsx--11'), new Cell('xlsx--11'),
new Cell('xlsx--12'), new Cell('xlsx--12'),
]); ]);
@ -130,7 +117,7 @@ class SheetTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::XLSX); $writer = WriterFactory::create(Type::XLSX);
$writer->openToFile($resourcePath); $writer->openToFile($resourcePath);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('xlsx--sheet1--11'), new Cell('xlsx--sheet1--11'),
new Cell('xlsx--sheet1--12'), new Cell('xlsx--sheet1--12'),
]); ]);
@ -138,7 +125,7 @@ class SheetTest extends \PHPUnit_Framework_TestCase
$writer->addNewSheetAndMakeItCurrent(); $writer->addNewSheetAndMakeItCurrent();
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('xlsx--sheet2--11'), new Cell('xlsx--sheet2--11'),
new Cell('xlsx--sheet2--12'), new Cell('xlsx--sheet2--12'),
new Cell('xlsx--sheet2--13'), new Cell('xlsx--sheet2--13'),

View File

@ -6,7 +6,6 @@ use Box\Spout\Common\Exception\SpoutException;
use Box\Spout\Common\Type; use Box\Spout\Common\Type;
use Box\Spout\TestUsingResource; use Box\Spout\TestUsingResource;
use Box\Spout\Writer\Common\Creator\EntityFactory; use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Creator\ManagerFactory;
use Box\Spout\Writer\Common\Entity\Cell; use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\WriterFactory; use Box\Spout\Writer\WriterFactory;
use Box\Spout\Writer\XLSX\Manager\WorksheetManager; use Box\Spout\Writer\XLSX\Manager\WorksheetManager;
@ -28,7 +27,7 @@ class WriterTest extends \PHPUnit_Framework_TestCase
*/ */
protected function setUp() protected function setUp()
{ {
$this->entityFactory = new EntityFactory(new ManagerFactory()); $this->entityFactory = new EntityFactory();
parent::setUp(); parent::setUp();
} }

View File

@ -6,11 +6,9 @@ use Box\Spout\Common\Type;
use Box\Spout\Reader\Wrapper\XMLReader; use Box\Spout\Reader\Wrapper\XMLReader;
use Box\Spout\TestUsingResource; use Box\Spout\TestUsingResource;
use Box\Spout\Writer\Common\Creator\EntityFactory; use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Creator\ManagerFactory;
use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\Common\Entity\Style\Border;
use Box\Spout\Writer\Common\Creator\Style\BorderBuilder; use Box\Spout\Writer\Common\Creator\Style\BorderBuilder;
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder; use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
use Box\Spout\Writer\Common\Entity\Cell;
use Box\Spout\Writer\Common\Entity\Style\Border; use Box\Spout\Writer\Common\Entity\Style\Border;
use Box\Spout\Writer\Common\Entity\Style\Color; use Box\Spout\Writer\Common\Entity\Style\Color;
use Box\Spout\Writer\Common\Entity\Style\Style; use Box\Spout\Writer\Common\Entity\Style\Style;
@ -28,18 +26,12 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
/** @var \Box\Spout\Writer\Common\Entity\Style\Style */ /** @var \Box\Spout\Writer\Common\Entity\Style\Style */
private $defaultStyle; private $defaultStyle;
/**
* @var EntityFactory
*/
protected $entityFactory;
/** /**
* @return void * @return void
*/ */
public function setUp() public function setUp()
{ {
$this->defaultStyle = (new StyleBuilder())->build(); $this->defaultStyle = (new StyleBuilder())->build();
$this->entityFactory = new EntityFactory(new ManagerFactory());
} }
/** /**
@ -48,7 +40,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
public function testAddRowWithStyleShouldThrowExceptionIfCallAddRowBeforeOpeningWriter() public function testAddRowWithStyleShouldThrowExceptionIfCallAddRowBeforeOpeningWriter()
{ {
$writer = WriterFactory::create(Type::XLSX); $writer = WriterFactory::create(Type::XLSX);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('xlsx--11'), new Cell('xlsx--11'),
new Cell('xlsx--12') new Cell('xlsx--12')
], $this->defaultStyle); ], $this->defaultStyle);
@ -61,7 +53,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
public function testAddRowsWithStyleShouldThrowExceptionIfCalledBeforeOpeningWriter() public function testAddRowsWithStyleShouldThrowExceptionIfCalledBeforeOpeningWriter()
{ {
$writer = WriterFactory::create(Type::XLSX); $writer = WriterFactory::create(Type::XLSX);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('xlsx--11'), new Cell('xlsx--11'),
new Cell('xlsx--12') new Cell('xlsx--12')
], $this->defaultStyle); ], $this->defaultStyle);
@ -98,7 +90,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::XLSX); $writer = WriterFactory::create(Type::XLSX);
$writer->openToFile($resourcePath); $writer->openToFile($resourcePath);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('xlsx--11'), new Cell('xlsx--11'),
new Cell('xlsx--12') new Cell('xlsx--12')
], $style); ], $style);
@ -124,7 +116,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
$writer = WriterFactory::create(Type::XLSX); $writer = WriterFactory::create(Type::XLSX);
$writer->openToFile($resourcePath); $writer->openToFile($resourcePath);
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('xlsx--11'), new Cell('xlsx--11'),
new Cell('xlsx--12') new Cell('xlsx--12')
], $style); ], $style);
@ -465,7 +457,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
{ {
$fileName = 'test_set_default_row_style.xlsx'; $fileName = 'test_set_default_row_style.xlsx';
$row = $this->entityFactory->createRow([ $row = EntityFactory::createRow([
new Cell('xlsx--11') new Cell('xlsx--11')
]); ]);
$dataRows = [$row]; $dataRows = [$row];
@ -563,7 +555,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
$arrayToRows = function(array $allRows) use ($style) { $arrayToRows = function(array $allRows) use ($style) {
return array_map(function ($oneRow) use ($style) { return array_map(function ($oneRow) use ($style) {
$row = $this->entityFactory->createRow(array_map(function ($value) { $row = EntityFactory::createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $oneRow), $style); }, $oneRow), $style);
return $row; return $row;
@ -632,7 +624,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
for ($i = 0; $i < count($allRows); $i++) { for ($i = 0; $i < count($allRows); $i++) {
$currentRow = $allRows[$i]; $currentRow = $allRows[$i];
$currentStyle = $styles[$i]; $currentStyle = $styles[$i];
$row = $this->entityFactory->createRow(array_map(function ($value) { $row = EntityFactory::createRow(array_map(function ($value) {
return new Cell($value); return new Cell($value);
}, $currentRow), $currentStyle); }, $currentRow), $currentStyle);
$writer->addRow($row); $writer->addRow($row);