add test for parsing HTML containing entities

This commit is contained in:
troosan 2018-11-28 22:02:39 +01:00
parent 78ffbff0c1
commit 7aef21faca
1 changed files with 15 additions and 0 deletions

View File

@ -86,6 +86,21 @@ class HtmlTest extends \PHPUnit\Framework\TestCase
$this->assertCount(2, $section->getElements());
}
/**
* Test HTML entities
*/
public function testParseHtmlEntities()
{
\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
Html::addHtml($section, 'text with entities <my text>');
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p[1]/w:r/w:t'));
$this->assertEquals('text with entities <my text>', $doc->getElement('/w:document/w:body/w:p[1]/w:r/w:t')->nodeValue);
}
/**
* Test underline
*/