From 16a9ded2c97304c89d0a7f1c4f34aa72c12e3818 Mon Sep 17 00:00:00 2001 From: troosan Date: Mon, 19 Mar 2018 22:49:00 +0100 Subject: [PATCH] add exact line spacing test --- tests/PhpWord/Shared/HtmlTest.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php index eda7abb8..386aaee1 100644 --- a/tests/PhpWord/Shared/HtmlTest.php +++ b/tests/PhpWord/Shared/HtmlTest.php @@ -20,6 +20,8 @@ namespace PhpOffice\PhpWord\Shared; use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\SimpleType\Jc; use PhpOffice\PhpWord\TestHelperDOCX; +use PhpOffice\PhpWord\Style\Paragraph; +use PhpOffice\PhpWord\SimpleType\LineSpacingRule; /** * Test class for PhpOffice\PhpWord\Shared\Html @@ -122,10 +124,16 @@ class HtmlTest extends \PHPUnit\Framework\TestCase $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); Html::addHtml($section, '

test

'); + Html::addHtml($section, '

test

'); $doc = TestHelperDOCX::getDocument($phpWord, 'Word2007'); - $this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:pPr/w:spacing')); - $this->assertEquals(240 * 1.5, $doc->getElementAttribute('/w:document/w:body/w:p/w:pPr/w:spacing', 'w:line')); + $this->assertTrue($doc->elementExists('/w:document/w:body/w:p[1]/w:pPr/w:spacing')); + $this->assertEquals(Paragraph::LINE_HEIGHT * 1.5, $doc->getElementAttribute('/w:document/w:body/w:p[1]/w:pPr/w:spacing', 'w:line')); + $this->assertEquals(LineSpacingRule::AUTO, $doc->getElementAttribute('/w:document/w:body/w:p[1]/w:pPr/w:spacing', 'w:lineRule')); + + $this->assertTrue($doc->elementExists('/w:document/w:body/w:p[2]/w:pPr/w:spacing')); + $this->assertEquals(300, $doc->getElementAttribute('/w:document/w:body/w:p[2]/w:pPr/w:spacing', 'w:line')); + $this->assertEquals(LineSpacingRule::EXACT, $doc->getElementAttribute('/w:document/w:body/w:p[2]/w:pPr/w:spacing', 'w:lineRule')); } /**