Skip to content

Commit 3c6a1a1

Browse files
committed
add unit test
1 parent 18b3c75 commit 3c6a1a1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/PhpWord/Writer/Word2007/ElementTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,4 +510,25 @@ public function testTextWithAmpersant()
510510
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:t'));
511511
$this->assertEquals('this text contains an & (ampersant)', $doc->getElement('/w:document/w:body/w:p/w:r/w:t')->nodeValue);
512512
}
513+
514+
/**
515+
* Test ListItemRun paragraph style writing
516+
*/
517+
public function testListItemRunStyleWriting()
518+
{
519+
$phpWord = new PhpWord();
520+
$phpWord->addParagraphStyle('MyParagraphStyle', array('spaceBefore' => 400));
521+
522+
$section = $phpWord->addSection();
523+
$listItemRun = $section->addListItemRun(0, null, 'MyParagraphStyle');
524+
$listItemRun->addText('List item');
525+
$listItemRun->addText(' in bold', array('bold' => true));
526+
527+
$doc = TestHelperDOCX::getDocument($phpWord);
528+
$this->assertFalse($doc->elementExists('/w:document/w:body/w:p/w:pPr/w:pPr'));
529+
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:pPr/w:pStyle'));
530+
$this->assertEquals('List item', $doc->getElement('/w:document/w:body/w:p/w:r[1]/w:t')->nodeValue);
531+
$this->assertEquals(' in bold', $doc->getElement('/w:document/w:body/w:p/w:r[2]/w:t')->nodeValue);
532+
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r[2]/w:rPr/w:b'));
533+
}
513534
}

0 commit comments

Comments
 (0)