Additional writer test
This commit is contained in:
parent
a65c3c3cf1
commit
991016a48b
|
|
@ -86,7 +86,7 @@ class String
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns unicode array from UTF8 text
|
* Returns unicode from UTF8 text
|
||||||
*
|
*
|
||||||
* The function is splitted to reduce cyclomatic complexity
|
* The function is splitted to reduce cyclomatic complexity
|
||||||
*
|
*
|
||||||
|
|
@ -100,7 +100,7 @@ class String
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns unicode from UTF8 text
|
* Returns unicode array from UTF8 text
|
||||||
*
|
*
|
||||||
* @param string $text UTF8 text
|
* @param string $text UTF8 text
|
||||||
* @return array
|
* @return array
|
||||||
|
|
|
||||||
|
|
@ -115,12 +115,14 @@ class Content extends AbstractPart
|
||||||
$xmlWriter->startElement('office:automatic-styles');
|
$xmlWriter->startElement('office:automatic-styles');
|
||||||
|
|
||||||
$this->writeTextStyles($xmlWriter);
|
$this->writeTextStyles($xmlWriter);
|
||||||
foreach ($this->autoStyles as $element => $style) {
|
foreach ($this->autoStyles as $element => $styles) {
|
||||||
$writerClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . $element;
|
$writerClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . $element;
|
||||||
|
foreach ($styles as $style) {
|
||||||
|
|
||||||
/** @var \PhpOffice\PhpWord\Writer\ODText\Style\AbstractStyle $styleWriter Type hint */
|
/** @var \PhpOffice\PhpWord\Writer\ODText\Style\AbstractStyle $styleWriter Type hint */
|
||||||
$styleWriter = new $writerClass($xmlWriter, $style);
|
$styleWriter = new $writerClass($xmlWriter, $style);
|
||||||
$styleWriter->write();
|
$styleWriter->write();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$xmlWriter->endElement(); // office:automatic-styles
|
$xmlWriter->endElement(); // office:automatic-styles
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,8 @@ class HTMLTest extends \PHPUnit_Framework_TestCase
|
||||||
$textrun = $section->addTextRun('Paragraph');
|
$textrun = $section->addTextRun('Paragraph');
|
||||||
$textrun->addLink('http://test.com');
|
$textrun->addLink('http://test.com');
|
||||||
$textrun->addImage($localImage);
|
$textrun->addImage($localImage);
|
||||||
$textrun->addFootnote();
|
$textrun->addFootnote()->addText('Footnote');
|
||||||
$textrun->addEndnote();
|
$textrun->addEndnote()->addText('Endnote');
|
||||||
|
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase
|
||||||
$phpWord->addFontStyle('Font', array('size' => 11));
|
$phpWord->addFontStyle('Font', array('size' => 11));
|
||||||
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
|
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
|
||||||
|
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection(array('colsNum' => 2));
|
||||||
$section->addText($expected);
|
$section->addText($expected);
|
||||||
$section->addText('Test font style', 'Font');
|
$section->addText('Test font style', 'Font');
|
||||||
$section->addText('Test paragraph style', null, 'Paragraph');
|
$section->addText('Test paragraph style', null, 'Paragraph');
|
||||||
|
|
@ -60,14 +60,14 @@ class ContentTest extends \PHPUnit_Framework_TestCase
|
||||||
$section->addTextBreak();
|
$section->addTextBreak();
|
||||||
$section->addPageBreak();
|
$section->addPageBreak();
|
||||||
$section->addListItem('Test list item');
|
$section->addListItem('Test list item');
|
||||||
$section->addImage($imageSrc);
|
$section->addImage($imageSrc, array('width' => 50));
|
||||||
$section->addObject($objectSrc);
|
$section->addObject($objectSrc);
|
||||||
$section->addTOC();
|
$section->addTOC();
|
||||||
|
|
||||||
$textrun = $section->addTextRun();
|
$textrun = $section->addTextRun();
|
||||||
$textrun->addText('Test text run');
|
$textrun->addText('Test text run');
|
||||||
|
|
||||||
$table = $section->addTable();
|
$table = $section->addTable(array('width' => 50));
|
||||||
$cell = $table->addRow()->addCell();
|
$cell = $table->addRow()->addCell();
|
||||||
$cell = $table->addRow()->addCell();
|
$cell = $table->addRow()->addCell();
|
||||||
$cell->addText('Test');
|
$cell->addText('Test');
|
||||||
|
|
@ -82,6 +82,8 @@ class ContentTest extends \PHPUnit_Framework_TestCase
|
||||||
$footer = $section->addFooter();
|
$footer = $section->addFooter();
|
||||||
$footer->addPreserveText('{PAGE}');
|
$footer->addPreserveText('{PAGE}');
|
||||||
|
|
||||||
|
$table = $section->addTable('tblStyle')->addRow()->addCell();
|
||||||
|
|
||||||
$doc = TestHelperDOCX::getDocument($phpWord, 'ODText');
|
$doc = TestHelperDOCX::getDocument($phpWord, 'ODText');
|
||||||
|
|
||||||
$element = "/office:document-content/office:body/office:text/text:section/text:p";
|
$element = "/office:document-content/office:body/office:text/text:section/text:p";
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testEmptyStyles()
|
public function testEmptyStyles()
|
||||||
{
|
{
|
||||||
$styles = array('Font', 'Paragraph');
|
$styles = array('Font', 'Paragraph', 'Image', 'Section', 'Table');
|
||||||
foreach ($styles as $style) {
|
foreach ($styles as $style) {
|
||||||
$objectClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . $style;
|
$objectClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . $style;
|
||||||
$xmlWriter = new XMLWriter();
|
$xmlWriter = new XMLWriter();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue