Border ordering (#273)
* Fix #271 * Minor fix for quick copy+paste * Added link to issue #271
This commit is contained in:
1 parent
54a1a09e29
commit
7a613eed8c
4 files changed
+75
-5
No files matched your search
@@ -268,6 +268,49 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(3, $styleXfsElements->getAttribute('count'), '3 cell xfs present');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testBordersCorrectOrder()
|
||||
{
|
||||
// Border should be Left, Right, Top, Bottom
|
||||
$fileName = 'test_borders_correct_order.xlsx';
|
||||
|
||||
$dataRows = [
|
||||
['I am a teapot'],
|
||||
];
|
||||
|
||||
$borders = (new BorderBuilder())
|
||||
->setBorderRight()
|
||||
->setBorderTop()
|
||||
->setBorderLeft()
|
||||
->setBorderBottom()
|
||||
->build();
|
||||
|
||||
$style = (new StyleBuilder())->setBorder($borders)->build();
|
||||
$this->writeToXLSXFile($dataRows, $fileName, $style);
|
||||
$borderElements = $this->getXmlSectionFromStylesXmlFile($fileName, 'borders');
|
||||
|
||||
$correctOrdering = [
|
||||
'left', 'right', 'top', 'bottom'
|
||||
];
|
||||
|
||||
/** @var $borderNode \DOMElement */
|
||||
foreach ($borderElements->childNodes as $borderNode) {
|
||||
$borderParts = $borderNode->childNodes;
|
||||
$ordering = [];
|
||||
|
||||
/** @var $part \DOMText */
|
||||
foreach ($borderParts as $part) {
|
||||
if ($part instanceof \DOMElement) {
|
||||
$ordering[] = $part->nodeName;
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEquals($correctOrdering, $ordering, 'The border parts are in correct ordering');
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $allRows
|
||||
* @param string $fileName
|
||||
|
||||
Reference in new issue
Block a user