getDocInfo(); $docProps->setCustomProperty('Company', 'PHPWord'); $phpWord->setDefaultFontName('Verdana'); $phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addParagraphStyle('Paragraph', array('alignment' => Jc::CENTER)); $phpWord->addTableStyle('tblStyle', array('width' => 100)); $section = $phpWord->addSection(array('colsNum' => 2)); $section->addText(htmlspecialchars($expected, ENT_COMPAT, 'UTF-8')); $section->addText(htmlspecialchars('Test font style', ENT_COMPAT, 'UTF-8'), 'Font'); $section->addText(htmlspecialchars('Test paragraph style', ENT_COMPAT, 'UTF-8'), null, 'Paragraph'); $section->addLink('https://github.com/PHPOffice/PHPWord', htmlspecialchars('PHPWord on GitHub', ENT_COMPAT, 'UTF-8')); $section->addTitle(htmlspecialchars('Test title', ENT_COMPAT, 'UTF-8'), 1); $section->addTextBreak(); $section->addPageBreak(); $section->addListItem(htmlspecialchars('Test list item', ENT_COMPAT, 'UTF-8')); $section->addImage($imageSrc, array('width' => 50)); $section->addObject($objectSrc); $section->addTOC(); $textrun = $section->addTextRun(); $textrun->addText(htmlspecialchars('Test text run', ENT_COMPAT, 'UTF-8')); $table = $section->addTable(array('width' => 50)); $cell = $table->addRow()->addCell(); $cell = $table->addRow()->addCell(); $cell->addText(htmlspecialchars('Test', ENT_COMPAT, 'UTF-8')); $cell->addLink('https://github.com/PHPOffice/PHPWord', htmlspecialchars('PHPWord on GitHub', ENT_COMPAT, 'UTF-8')); $cell->addTextBreak(); $cell->addListItem(htmlspecialchars('Test list item', ENT_COMPAT, 'UTF-8')); $cell->addImage($imageSrc); $cell->addObject($objectSrc); $textrun = $cell->addTextRun(); $textrun->addText(htmlspecialchars('Test text run', ENT_COMPAT, 'UTF-8')); $footer = $section->addFooter(); $footer->addPreserveText(htmlspecialchars('{PAGE}', ENT_COMPAT, 'UTF-8')); $table = $section->addTable('tblStyle')->addRow()->addCell(); $doc = TestHelperDOCX::getDocument($phpWord, 'ODText'); $element = '/office:document-content/office:body/office:text/text:section/text:p'; $this->assertEquals($expected, $doc->getElement($element, 'content.xml')->nodeValue); } /** * Test no paragraph style */ public function testWriteNoStyle() { $phpWord = new PhpWord(); $phpWord->addFontStyle('Font', array('size' => 11)); $doc = TestHelperDOCX::getDocument($phpWord, 'ODText'); $element = '/office:document-content/office:automatic-styles/style:style'; $this->assertTrue($doc->elementExists($element, 'content.xml')); } }