@@ -233,4 +233,66 @@ public function testReadHeadingWithOverriddenStyle(): void
233
233
self ::assertInstanceOf ('PhpOffice\PhpWord\Element\Text ' , $ text );
234
234
self ::assertEquals (' but with parts not in bold ' , $ text ->getText ());
235
235
}
236
+
237
+ public function testReadSymbol (): void
238
+ {
239
+ $ documentXml = '<w:p>
240
+ <w:r>
241
+ <w:t>Text before symbol </w:t>
242
+ </w:r>
243
+ <w:r>
244
+ <w:sym w:font="Wingdings 2" w:char="00A3"/>
245
+ </w:r>
246
+ <w:r>
247
+ <w:t> text after symbol</w:t>
248
+ </w:r>
249
+ </w:p>
250
+ <w:p>
251
+ <w:r>
252
+ <w:t>Another symbol: </w:t>
253
+ </w:r>
254
+ <w:r>
255
+ <w:sym w:font="Wingdings 2" w:char="0052"/>
256
+ </w:r>
257
+ </w:p> ' ;
258
+
259
+ $ phpWord = $ this ->getDocumentFromString (['document ' => $ documentXml ]);
260
+
261
+ $ elements = $ phpWord ->getSection (0 )->getElements ();
262
+
263
+ // Test first paragraph with symbol
264
+ self ::assertInstanceOf ('PhpOffice\PhpWord\Element\TextRun ' , $ elements [0 ]);
265
+ /** @var \PhpOffice\PhpWord\Element\TextRun $textRun1 */
266
+ $ textRun1 = $ elements [0 ];
267
+
268
+ /** @var \PhpOffice\PhpWord\Element\Text $text1 */
269
+ $ text1 = $ textRun1 ->getElement (0 );
270
+ self ::assertInstanceOf ('PhpOffice\PhpWord\Element\Text ' , $ text1 );
271
+ self ::assertEquals ('Text before symbol ' , $ text1 ->getText ());
272
+
273
+ /** @var \PhpOffice\PhpWord\Element\Text $symbol1 */
274
+ $ symbol1 = $ textRun1 ->getElement (1 );
275
+ self ::assertInstanceOf ('PhpOffice\PhpWord\Element\Text ' , $ symbol1 );
276
+ self ::assertEquals ('[Wingdings 2,00A3] ' , $ symbol1 ->getText ());
277
+
278
+ /** @var \PhpOffice\PhpWord\Element\Text $text2 */
279
+ $ text2 = $ textRun1 ->getElement (2 );
280
+ self ::assertInstanceOf ('PhpOffice\PhpWord\Element\Text ' , $ text2 );
281
+ self ::assertEquals (' text after symbol ' , $ text2 ->getText ());
282
+
283
+ // Test second paragraph with different symbol
284
+ self ::assertInstanceOf ('PhpOffice\PhpWord\Element\TextRun ' , $ elements [1 ]);
285
+ /** @var \PhpOffice\PhpWord\Element\TextRun $textRun2 */
286
+ $ textRun2 = $ elements [1 ];
287
+
288
+ /** @var \PhpOffice\PhpWord\Element\Text $text3 */
289
+ $ text3 = $ textRun2 ->getElement (0 );
290
+ self ::assertInstanceOf ('PhpOffice\PhpWord\Element\Text ' , $ text3 );
291
+ self ::assertEquals ('Another symbol: ' , $ text3 ->getText ());
292
+
293
+ /** @var \PhpOffice\PhpWord\Element\Text $symbol2 */
294
+ $ symbol2 = $ textRun2 ->getElement (1 );
295
+ self ::assertInstanceOf ('PhpOffice\PhpWord\Element\Text ' , $ symbol2 );
296
+ self ::assertEquals ('[Wingdings 2,0052] ' , $ symbol2 ->getText ());
297
+ }
236
298
}
0 commit comments