Skip to content

Commit f406ad0

Browse files
committed
provide test for missing text in lists with format
1 parent 05edb7e commit f406ad0

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

tests/PhpWord/Shared/HtmlTest.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,11 @@ public function testParseList()
215215
$phpWord = new \PhpOffice\PhpWord\PhpWord();
216216
$section = $phpWord->addSection();
217217
$html = '<ul>
218-
<li>
218+
<li>Some text before
219219
<span style="font-family: arial,helvetica,sans-serif;">
220220
<span style="font-size: 12px;">list item1</span>
221221
</span>
222+
and some after
222223
</li>
223224
<li>
224225
<span style="font-family: arial,helvetica,sans-serif;">
@@ -235,6 +236,36 @@ public function testParseList()
235236
$this->assertEquals('list item2', $doc->getElement('/w:document/w:body/w:p[2]/w:r/w:t')->nodeValue);
236237
}
237238

239+
240+
/**
241+
* Tests parsing of ul/li
242+
*/
243+
public function testParseListWithFormat()
244+
{
245+
$phpWord = new \PhpOffice\PhpWord\PhpWord();
246+
$section = $phpWord->addSection();
247+
$html = '<ul>
248+
<li>Some text before
249+
<span style="font-family: arial,helvetica,sans-serif;">
250+
<span style="font-size: 12px;">list item1</span> <b>bold</b> with text after bold
251+
</span>
252+
and some after
253+
</li>
254+
<li>
255+
<span style="font-family: arial,helvetica,sans-serif;">
256+
<span style="font-size: 12px;">list item2</span>
257+
</span>
258+
</li>
259+
</ul>';
260+
Html::addHtml($section, $html, false, false);
261+
262+
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
263+
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:pPr/w:numPr/w:numId'));
264+
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:t'));
265+
$this->assertEquals('Some text before list item1 bold with text after bold and some after', $doc->getElement('/w:document/w:body/w:p[1]/w:r/w:t')->nodeValue);
266+
$this->assertEquals('list item2', $doc->getElement('/w:document/w:body/w:p[2]/w:r/w:t')->nodeValue);
267+
}
268+
238269
/**
239270
* Tests parsing of br
240271
*/

0 commit comments

Comments
 (0)