@@ -34,7 +34,7 @@ class ElementTest extends \PHPUnit\Framework\TestCase
3434 */
3535 public function testUnmatchedElements ()
3636 {
37- $ elements = array ('Container ' , 'Footnote ' , 'Image ' , 'Link ' , 'ListItem ' , 'Table ' , 'Title ' , 'Bookmark ' );
37+ $ elements = array ('Container ' , 'Footnote ' , 'Image ' , 'Link ' , 'ListItem ' , 'ListItemRun ' , ' Table ' , 'Title ' , 'Bookmark ' );
3838 foreach ($ elements as $ element ) {
3939 $ objectClass = 'PhpOffice \\PhpWord \\Writer \\HTML \\Element \\' . $ element ;
4040 $ parentWriter = new HTML ();
@@ -163,6 +163,31 @@ public function testWriteTitleTextRun()
163163 $ this ->assertContains ($ expected , $ content );
164164 }
165165
166+ /**
167+ * Test write element ListItemRun
168+ */
169+ public function testListItemRun ()
170+ {
171+ $ expected1 = 'List item run 1 ' ;
172+ $ expected2 = 'List item run 1 in bold ' ;
173+
174+ $ phpWord = new PhpWord ();
175+ $ section = $ phpWord ->addSection ();
176+
177+ $ listItemRun = $ section ->addListItemRun (0 , null , 'MyParagraphStyle ' );
178+ $ listItemRun ->addText ($ expected1 );
179+ $ listItemRun ->addText ($ expected2 , array ('bold ' => true ));
180+
181+ $ htmlWriter = new HTML ($ phpWord );
182+ $ content = $ htmlWriter ->getContent ();
183+
184+ $ dom = new \DOMDocument ();
185+ $ dom ->loadHTML ($ content );
186+
187+ $ this ->assertEquals ($ expected1 , $ dom ->getElementsByTagName ('p ' )->item (0 )->textContent );
188+ $ this ->assertEquals ($ expected2 , $ dom ->getElementsByTagName ('p ' )->item (1 )->textContent );
189+ }
190+
166191 /**
167192 * Tests writing table with layout
168193 */
0 commit comments