@@ -267,17 +267,24 @@ public function testSDTElements()
267
267
$ phpWord = new PhpWord ();
268
268
$ section = $ phpWord ->addSection ();
269
269
270
- $ section ->addSDT ('comboBox ' );
270
+ $ section ->addSDT ('comboBox ' )-> setListItems ( array ( ' 1 ' => ' Choice 1 ' , ' 2 ' => ' Choice 2 ' ))-> setValue ( ' select value ' ) ;
271
271
$ section ->addSDT ('dropDownList ' );
272
272
$ section ->addSDT ('date ' )->setAlias ('date_alias ' )->setTag ('my_tag ' );
273
273
274
274
$ doc = TestHelperDOCX::getDocument ($ phpWord );
275
275
276
276
$ path = '/w:document/w:body/w:p ' ;
277
277
278
+ $ this ->assertTrue ($ doc ->elementExists ($ path . '[1]/w:sdt/w:sdtContent/w:r/w:t ' ));
279
+ $ this ->assertEquals ('select value ' , $ doc ->getElement ($ path . '[1]/w:sdt/w:sdtContent/w:r/w:t ' )->nodeValue );
278
280
$ this ->assertTrue ($ doc ->elementExists ($ path . '[1]/w:sdt/w:sdtPr/w:comboBox ' ));
281
+ $ this ->assertTrue ($ doc ->elementExists ($ path . '[1]/w:sdt/w:sdtPr/w:comboBox/w:listItem ' ));
282
+ $ this ->assertEquals ('1 ' , $ doc ->getElementAttribute ($ path . '[1]/w:sdt/w:sdtPr/w:comboBox/w:listItem[1] ' , 'w:value ' ));
283
+ $ this ->assertEquals ('Choice 1 ' , $ doc ->getElementAttribute ($ path . '[1]/w:sdt/w:sdtPr/w:comboBox/w:listItem[1] ' , 'w:displayText ' ));
284
+
279
285
$ this ->assertTrue ($ doc ->elementExists ($ path . '[2]/w:sdt/w:sdtPr/w:dropDownList ' ));
280
286
$ this ->assertFalse ($ doc ->elementExists ($ path . '[2]/w:sdt/w:sdtPr/w:alias ' ));
287
+
281
288
$ this ->assertTrue ($ doc ->elementExists ($ path . '[3]/w:sdt/w:sdtPr/w:date ' ));
282
289
$ this ->assertTrue ($ doc ->elementExists ($ path . '[3]/w:sdt/w:sdtPr/w:alias ' ));
283
290
$ this ->assertTrue ($ doc ->elementExists ($ path . '[3]/w:sdt/w:sdtPr/w:tag ' ));
0 commit comments