From e07195c512a066db0469259290391f3ea6bf6a62 Mon Sep 17 00:00:00 2001 From: troosan Date: Wed, 22 Nov 2017 08:14:22 +0100 Subject: [PATCH] add test, fix warnings --- src/PhpWord/Shared/Html.php | 2 +- src/PhpWord/Style/Paragraph.php | 2 +- src/PhpWord/Style/Spacing.php | 2 +- tests/PhpWord/Style/ParagraphTest.php | 2 +- .../Writer/Word2007/Part/DocumentTest.php | 23 ++++++++++++++++++- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 5319c879..027d5798 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -18,10 +18,10 @@ namespace PhpOffice\PhpWord\Shared; use PhpOffice\PhpWord\Element\AbstractContainer; +use PhpOffice\PhpWord\Element\Cell; use PhpOffice\PhpWord\Element\Row; use PhpOffice\PhpWord\Element\Table; use PhpOffice\PhpWord\SimpleType\Jc; -use PhpOffice\PhpWord\Element\Cell; /** * Common Html functions diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 3b45344c..c00dc97c 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -20,8 +20,8 @@ namespace PhpOffice\PhpWord\Style; use PhpOffice\Common\Text; use PhpOffice\PhpWord\Exception\InvalidStyleException; use PhpOffice\PhpWord\SimpleType\Jc; -use PhpOffice\PhpWord\SimpleType\TextAlignment; use PhpOffice\PhpWord\SimpleType\LineSpacingRule; +use PhpOffice\PhpWord\SimpleType\TextAlignment; /** * Paragraph style diff --git a/src/PhpWord/Style/Spacing.php b/src/PhpWord/Style/Spacing.php index a932eb1a..eaa15814 100644 --- a/src/PhpWord/Style/Spacing.php +++ b/src/PhpWord/Style/Spacing.php @@ -143,7 +143,7 @@ class Spacing extends AbstractStyle { return $this->lineRule; } - + /** * Set line rule * diff --git a/tests/PhpWord/Style/ParagraphTest.php b/tests/PhpWord/Style/ParagraphTest.php index 68c0c12e..e961f36a 100644 --- a/tests/PhpWord/Style/ParagraphTest.php +++ b/tests/PhpWord/Style/ParagraphTest.php @@ -18,8 +18,8 @@ namespace PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\TestHelperDOCX; use PhpOffice\PhpWord\SimpleType\LineSpacingRule; +use PhpOffice\PhpWord\TestHelperDOCX; /** * Test class for PhpOffice\PhpWord\Style\Paragraph diff --git a/tests/PhpWord/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Writer/Word2007/Part/DocumentTest.php index ddc7fc10..42c098cd 100644 --- a/tests/PhpWord/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Writer/Word2007/Part/DocumentTest.php @@ -22,7 +22,9 @@ use PhpOffice\PhpWord\Metadata\DocInfo; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\SimpleType\Jc; use PhpOffice\PhpWord\SimpleType\NumberFormat; +use PhpOffice\PhpWord\Style\Cell; use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\TestHelperDOCX; /** @@ -532,6 +534,25 @@ class DocumentTest extends \PHPUnit\Framework\TestCase $this->assertTrue($doc->elementExists("{$parent}/w:smallCaps")); } + /** + * Tests that if no color is set on a cell a border gets writen with the default color + */ + public function testWriteDefaultColor() + { + $phpWord = new PhpWord(); + $section = $phpWord->addSection(); + + $cStyles['borderTopSize'] = 120; + + $table = $section->addTable(); + $table->addRow(); + $cell = $table->addCell(null, $cStyles); + $cell->addText('Test'); + + $doc = TestHelperDOCX::getDocument($phpWord); + $this->assertEquals(Cell::DEFAULT_BORDER_COLOR, $doc->getElementAttribute('/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:tcBorders/w:top', 'w:color')); + } + /** * covers ::_writeTableStyle */ @@ -565,7 +586,7 @@ class DocumentTest extends \PHPUnit\Framework\TestCase $section = $phpWord->addSection(); $table = $section->addTable($tStyles); - $table->setWidth = 100; + $table->setWidth(100); $table->addRow($rHeight, $rStyles); $cell = $table->addCell($cWidth, $cStyles); $cell->addText('Test');