#729 - fix shrink to fit + add test

shrinkToFit was not handled in StyleMerger so it was overwritten by the default cell style
StyleManager didn't add the property to the xml if shrinkToFit was used without alignment or text wrap.
Unit test
This commit is contained in:
István Ignácz committed 2020-08-14 16:39:52 +02:00
1 parent f702127d3a
commit 817e4f1f01
5 files changed
+36 -4

No files matched your search

@@ -306,6 +306,24 @@ class WriterWithStyleTest extends TestCase
$this->assertFirstChildHasAttributeEquals(CellAlignment::RIGHT, $xfElement, 'alignment', 'horizontal');
}
/**
* @return void
*/
public function testAddRowShouldApplyShrinkToFit()
{
$fileName = 'test_add_row_should_apply_shrink_to_fit.xlsx';
$shrinkToFitStyle = (new StyleBuilder())->setShouldShrinkToFit()->build();
$dataRows = $this->createStyledRowsFromValues([['xlsx--11']], $shrinkToFitStyle);
$this->writeToXLSXFile($dataRows, $fileName);
$cellXfsDomElement = $this->getXmlSectionFromStylesXmlFile($fileName, 'cellXfs');
$xfElement = $cellXfsDomElement->getElementsByTagName('xf')->item(1);
$this->assertEquals(1, $xfElement->getAttribute('applyAlignment'));
$this->assertFirstChildHasAttributeEquals("true", $xfElement, 'alignment', 'shrinkToFit');
}
/**
* @return void
*/