Skip to content

Commit 56a3a53

Browse files
committed
add unit test
1 parent 5ddb3f0 commit 56a3a53

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tests/PhpWord/Writer/Word2007/ElementTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,24 @@ public function testSDTElements()
267267
$phpWord = new PhpWord();
268268
$section = $phpWord->addSection();
269269

270-
$section->addSDT('comboBox');
270+
$section->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'))->setValue('select value');
271271
$section->addSDT('dropDownList');
272272
$section->addSDT('date')->setAlias('date_alias')->setTag('my_tag');
273273

274274
$doc = TestHelperDOCX::getDocument($phpWord);
275275

276276
$path = '/w:document/w:body/w:p';
277277

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);
278280
$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+
279285
$this->assertTrue($doc->elementExists($path . '[2]/w:sdt/w:sdtPr/w:dropDownList'));
280286
$this->assertFalse($doc->elementExists($path . '[2]/w:sdt/w:sdtPr/w:alias'));
287+
281288
$this->assertTrue($doc->elementExists($path . '[3]/w:sdt/w:sdtPr/w:date'));
282289
$this->assertTrue($doc->elementExists($path . '[3]/w:sdt/w:sdtPr/w:alias'));
283290
$this->assertTrue($doc->elementExists($path . '[3]/w:sdt/w:sdtPr/w:tag'));

0 commit comments

Comments
 (0)