Merge 887d6ef033 into 8459666841
This commit is contained in:
11 files changed
+229
-24
No files matched your search
@@ -4,6 +4,7 @@ namespace Box\Spout\Writer\Common\Creator\Style;
|
||||
|
||||
use Box\Spout\Common\Entity\Style\Border;
|
||||
use Box\Spout\Common\Entity\Style\CellAlignment;
|
||||
use Box\Spout\Common\Entity\Style\CellVerticalAlignment;
|
||||
use Box\Spout\Common\Entity\Style\Color;
|
||||
use Box\Spout\Common\Exception\InvalidArgumentException;
|
||||
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
|
||||
@@ -53,6 +54,15 @@ class StyleBuilderTest extends TestCase
|
||||
$this->assertTrue($style->shouldApplyCellAlignment());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testStyleBuilderShouldApplyCellVerticalAlignment()
|
||||
{
|
||||
$style = (new StyleBuilder())->setCellVerticalAlignment(CellVerticalAlignment::CENTER)->build();
|
||||
$this->assertTrue($style->shouldApplyCellVerticalAlignment());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
@@ -61,4 +71,13 @@ class StyleBuilderTest extends TestCase
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
(new StyleBuilder())->setCellAlignment('invalid_cell_alignment')->build();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testStyleBuilderShouldThrowOnInvalidCellVerticalAlignment()
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
(new StyleBuilder())->setCellVerticalAlignment('invalid_cell_alignment')->build();
|
||||
}
|
||||
}
|
||||
@@ -188,6 +188,27 @@ class WriterWithStyleTest extends TestCase
|
||||
$this->assertFirstChildHasAttributeEquals('wrap', $customStyleElement, 'table-cell-properties', 'fo:wrap-option');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testAddRowShouldAddNegatedWrapTextAlignmentInfoInStylesXmlFileIfSpecified()
|
||||
{
|
||||
$fileName = 'test_add_row_should_add_negated_wrap_text_alignment.ods';
|
||||
|
||||
$style = (new StyleBuilder())->setShouldWrapText(false)->build();
|
||||
$dataRows = $this->createStyledRowsFromValues([
|
||||
['ods--11', 'ods--12'],
|
||||
], $style);
|
||||
|
||||
$this->writeToODSFile($dataRows, $fileName);
|
||||
|
||||
$styleElements = $this->getCellStyleElementsFromContentXmlFile($fileName);
|
||||
$this->assertCount(2, $styleElements, 'There should be 2 styles (default and custom)');
|
||||
|
||||
$customStyleElement = $styleElements[1];
|
||||
$this->assertFirstChildHasAttributeEquals('no-wrap', $customStyleElement, 'table-cell-properties', 'fo:wrap-option');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -271,6 +271,26 @@ class WriterWithStyleTest extends TestCase
|
||||
$this->assertFirstChildHasAttributeEquals('1', $xfElement, 'alignment', 'wrapText');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testAddRowShouldAddNegatedWrapTextAlignmentInfoInStylesXmlFileIfSpecified()
|
||||
{
|
||||
$fileName = 'test_add_row_should_add_negated_wrap_text_alignment.xlsx';
|
||||
|
||||
$style = (new StyleBuilder())->setShouldWrapText(false)->build();
|
||||
$dataRows = $this->createStyledRowsFromValues([
|
||||
['xlsx--11', 'xlsx--12'],
|
||||
], $style);
|
||||
|
||||
$this->writeToXLSXFile($dataRows, $fileName);
|
||||
|
||||
$cellXfsDomElement = $this->getXmlSectionFromStylesXmlFile($fileName, 'cellXfs');
|
||||
$xfElement = $cellXfsDomElement->getElementsByTagName('xf')->item(1);
|
||||
$this->assertEquals(1, $xfElement->getAttribute('applyAlignment'));
|
||||
$this->assertFirstChildHasAttributeEquals('0', $xfElement, 'alignment', 'wrapText');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user