@@ -34,7 +34,7 @@ class ElementTest extends \PHPUnit\Framework\TestCase
34
34
*/
35
35
public function testUnmatchedElements ()
36
36
{
37
- $ elements = array ('Container ' , 'Footnote ' , 'Image ' , 'Link ' , 'ListItem ' , 'Table ' , 'Title ' , 'Bookmark ' );
37
+ $ elements = array ('Container ' , 'Footnote ' , 'Image ' , 'Link ' , 'ListItem ' , 'ListItemRun ' , ' Table ' , 'Title ' , 'Bookmark ' );
38
38
foreach ($ elements as $ element ) {
39
39
$ objectClass = 'PhpOffice \\PhpWord \\Writer \\HTML \\Element \\' . $ element ;
40
40
$ parentWriter = new HTML ();
@@ -163,6 +163,31 @@ public function testWriteTitleTextRun()
163
163
$ this ->assertContains ($ expected , $ content );
164
164
}
165
165
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
+
166
191
/**
167
192
* Tests writing table with layout
168
193
*/
0 commit comments