add unit tests
This commit is contained in:
parent
46a5f96d3b
commit
47c837abef
|
|
@ -366,10 +366,6 @@ class Html
|
|||
*/
|
||||
private static function shouldAddTextRun(\DOMNode $node)
|
||||
{
|
||||
if (!$node->hasChildNodes()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$containsBlockElement = self::$xpath->query('.//table|./p', $node)->length > 0;
|
||||
if ($containsBlockElement) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -150,6 +150,33 @@ class HtmlTest extends \PHPUnit\Framework\TestCase
|
|||
$this->assertEquals('15', $doc->getElementAttribute('/w:document/w:body/w:p[2]/w:r/w:rPr/w:sz', 'w:val'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test direction style
|
||||
*/
|
||||
public function testParseTextDirection()
|
||||
{
|
||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||
$section = $phpWord->addSection();
|
||||
Html::addHtml($section, '<span style="direction: rtl">test</span>');
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
|
||||
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:rPr/w:rtl'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test html lang
|
||||
*/
|
||||
public function testParseLang()
|
||||
{
|
||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||
$section = $phpWord->addSection();
|
||||
Html::addHtml($section, '<span lang="fr-BE">test</span>');
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
|
||||
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:rPr/w:lang'));
|
||||
$this->assertEquals('fr-BE', $doc->getElementAttribute('/w:document/w:body/w:p/w:r/w:rPr/w:lang', 'w:val'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test font-family style
|
||||
*/
|
||||
|
|
@ -199,7 +226,7 @@ class HtmlTest extends \PHPUnit\Framework\TestCase
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr><td style="border-style: dotted;">1</td><td colspan="2">2</td></tr>
|
||||
<tr><td>4</td><td>5</td><td>6</td></tr>
|
||||
<tr><td>This is <b>bold</b> text</td><td>5</td><td><p>6</p></td></tr>
|
||||
</tbody>
|
||||
</table>';
|
||||
Html::addHtml($section, $html);
|
||||
|
|
|
|||
Loading…
Reference in New Issue