Row objects and Cell styling
This commit introduces Row and Cell entities, that will replace the arrays passed in previously. It also adds support for Cell styling (instead of Row styling only).
This commit is contained in:
1 parent
fec27e9056
commit
7274226b75
32 files changed
+1113
-859
No files matched your search
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
|
||||
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
|
||||
*/
|
||||
public function dataProviderForTestIsEmptyRow()
|
||||
{
|
||||
return [
|
||||
// cells, expected isEmpty
|
||||
[[], true],
|
||||
[[new Cell('')], true],
|
||||
[[new Cell(''), new Cell(''), new Cell('Okay')], false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataProviderForTestIsEmptyRow
|
||||
*
|
||||
* @param array $cells
|
||||
* @param bool $expectedIsEmpty
|
||||
* @return void
|
||||
*/
|
||||
public function testIsEmptyRow(array $cells, $expectedIsEmpty)
|
||||
{
|
||||
$rowManager = new RowManager(new StyleMerger());
|
||||
|
||||
$row = new Row($cells, null, $rowManager);
|
||||
$this->assertEquals($expectedIsEmpty, $rowManager->isEmpty($row));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user