Skip to content

Commit 16a9ded

Browse files
committed
add exact line spacing test
1 parent de01e86 commit 16a9ded

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests/PhpWord/Shared/HtmlTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
use PhpOffice\PhpWord\Element\Section;
2121
use PhpOffice\PhpWord\SimpleType\Jc;
2222
use PhpOffice\PhpWord\TestHelperDOCX;
23+
use PhpOffice\PhpWord\Style\Paragraph;
24+
use PhpOffice\PhpWord\SimpleType\LineSpacingRule;
2325

2426
/**
2527
* Test class for PhpOffice\PhpWord\Shared\Html
@@ -122,10 +124,16 @@ public function testParseLineHeight()
122124
$phpWord = new \PhpOffice\PhpWord\PhpWord();
123125
$section = $phpWord->addSection();
124126
Html::addHtml($section, '<p style="line-height: 1.5;">test</p>');
127+
Html::addHtml($section, '<p style="line-height: 15pt;">test</p>');
125128

126129
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
127-
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:pPr/w:spacing'));
128-
$this->assertEquals(240 * 1.5, $doc->getElementAttribute('/w:document/w:body/w:p/w:pPr/w:spacing', 'w:line'));
130+
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p[1]/w:pPr/w:spacing'));
131+
$this->assertEquals(Paragraph::LINE_HEIGHT * 1.5, $doc->getElementAttribute('/w:document/w:body/w:p[1]/w:pPr/w:spacing', 'w:line'));
132+
$this->assertEquals(LineSpacingRule::AUTO, $doc->getElementAttribute('/w:document/w:body/w:p[1]/w:pPr/w:spacing', 'w:lineRule'));
133+
134+
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p[2]/w:pPr/w:spacing'));
135+
$this->assertEquals(300, $doc->getElementAttribute('/w:document/w:body/w:p[2]/w:pPr/w:spacing', 'w:line'));
136+
$this->assertEquals(LineSpacingRule::EXACT, $doc->getElementAttribute('/w:document/w:body/w:p[2]/w:pPr/w:spacing', 'w:lineRule'));
129137
}
130138

131139
/**

0 commit comments

Comments
 (0)