Add test and fix warnings

This commit is contained in:
troosan 2018-12-26 22:50:19 +01:00
parent 5e2374be4a
commit d84da93a36
2 changed files with 7 additions and 4 deletions

View File

@ -78,13 +78,13 @@ class SDT extends Text
* *
* @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtText.html * @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtText.html
* @param \PhpOffice\Common\XMLWriter $xmlWriter * @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\SDT $element
*/ */
private function writePlainText(XMLWriter $xmlWriter, SDTElement $element) private function writePlainText(XMLWriter $xmlWriter)
{ {
$xmlWriter->startElement("w:text"); $xmlWriter->startElement('w:text');
$xmlWriter->endElement(); // w:{$type} $xmlWriter->endElement(); // w:text
} }
/** /**
* Write combo box. * Write combo box.
* *

View File

@ -387,6 +387,7 @@ class ElementTest extends \PHPUnit\Framework\TestCase
$section->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'))->setValue('select value'); $section->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'))->setValue('select value');
$section->addSDT('dropDownList'); $section->addSDT('dropDownList');
$section->addSDT('date')->setAlias('date_alias')->setTag('my_tag'); $section->addSDT('date')->setAlias('date_alias')->setTag('my_tag');
$section->addSDT('plainText');
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);
@ -405,6 +406,8 @@ class ElementTest extends \PHPUnit\Framework\TestCase
$this->assertTrue($doc->elementExists($path . '[3]/w:sdt/w:sdtPr/w:date')); $this->assertTrue($doc->elementExists($path . '[3]/w:sdt/w:sdtPr/w:date'));
$this->assertTrue($doc->elementExists($path . '[3]/w:sdt/w:sdtPr/w:alias')); $this->assertTrue($doc->elementExists($path . '[3]/w:sdt/w:sdtPr/w:alias'));
$this->assertTrue($doc->elementExists($path . '[3]/w:sdt/w:sdtPr/w:tag')); $this->assertTrue($doc->elementExists($path . '[3]/w:sdt/w:sdtPr/w:tag'));
$this->assertTrue($doc->elementExists($path . '[4]/w:sdt/w:sdtPr/w:text'));
} }
/** /**