StyleMerger and RowManager changes
Move DI of StyleMerger to get rid of business logic in the entities Cell and Row Simplify RowManager
This commit is contained in:
1 parent
111f82d35f
commit
ddfa40e8b3
10 files changed
+67
-166
No files matched your search
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Spout\Writer\Common\Manager;
|
||||
|
||||
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
|
||||
use Box\Spout\Writer\Common\Entity\Cell;
|
||||
use Box\Spout\Writer\Common\Entity\Row;
|
||||
use Box\Spout\Writer\Common\Manager\RowManager;
|
||||
@@ -11,51 +10,6 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RowManagerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testApplyStyle()
|
||||
{
|
||||
$rowManager = new RowManager(new StyleMerger());
|
||||
$row = new Row([new Cell('test')], null, $rowManager);
|
||||
|
||||
$this->assertFalse($row->getStyle()->isFontBold());
|
||||
|
||||
$style = (new StyleBuilder())->setFontBold()->build();
|
||||
$rowManager->applyStyle($row, $style);
|
||||
|
||||
$this->assertTrue($row->getStyle()->isFontBold());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function dataProviderForTestHasCells()
|
||||
{
|
||||
return [
|
||||
// cells, expected hasCells
|
||||
[[], false],
|
||||
[[new Cell('')], true],
|
||||
[[new Cell(null)], true],
|
||||
[[new Cell('test')], true],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataProviderForTestHasCells
|
||||
*
|
||||
* @param array $cells
|
||||
* @param bool $expectedHasCells
|
||||
* @return void
|
||||
*/
|
||||
public function testHasCells(array $cells, $expectedHasCells)
|
||||
{
|
||||
$rowManager = new RowManager(new StyleMerger());
|
||||
|
||||
$row = new Row($cells, null, $rowManager);
|
||||
$this->assertEquals($expectedHasCells, $rowManager->hasCells($row));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user