Skip to content

Commit 7aef21f

Browse files
committed
add test for parsing HTML containing entities
1 parent 78ffbff commit 7aef21f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/PhpWord/Shared/HtmlTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ public function testParseFullHtml()
8686
$this->assertCount(2, $section->getElements());
8787
}
8888

89+
/**
90+
* Test HTML entities
91+
*/
92+
public function testParseHtmlEntities()
93+
{
94+
\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
95+
$phpWord = new \PhpOffice\PhpWord\PhpWord();
96+
$section = $phpWord->addSection();
97+
Html::addHtml($section, 'text with entities <my text>');
98+
99+
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
100+
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p[1]/w:r/w:t'));
101+
$this->assertEquals('text with entities <my text>', $doc->getElement('/w:document/w:body/w:p[1]/w:r/w:t')->nodeValue);
102+
}
103+
89104
/**
90105
* Test underline
91106
*/

0 commit comments

Comments
 (0)