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