Additional writer test

This commit is contained in:
Ivan Lanin 2014-05-24 00:11:06 +07:00
parent a65c3c3cf1
commit 991016a48b
5 changed files with 16 additions and 12 deletions

View File

@ -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
*
@ -100,7 +100,7 @@ class String
}
/**
* Returns unicode from UTF8 text
* Returns unicode array from UTF8 text
*
* @param string $text UTF8 text
* @return array

View File

@ -115,12 +115,14 @@ class Content extends AbstractPart
$xmlWriter->startElement('office:automatic-styles');
$this->writeTextStyles($xmlWriter);
foreach ($this->autoStyles as $element => $style) {
foreach ($this->autoStyles as $element => $styles) {
$writerClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . $element;
foreach ($styles as $style) {
/** @var \PhpOffice\PhpWord\Writer\ODText\Style\AbstractStyle $styleWriter Type hint */
$styleWriter = new $writerClass($xmlWriter, $style);
$styleWriter->write();
/** @var \PhpOffice\PhpWord\Writer\ODText\Style\AbstractStyle $styleWriter Type hint */
$styleWriter = new $writerClass($xmlWriter, $style);
$styleWriter->write();
}
}
$xmlWriter->endElement(); // office:automatic-styles

View File

@ -92,8 +92,8 @@ class HTMLTest extends \PHPUnit_Framework_TestCase
$textrun = $section->addTextRun('Paragraph');
$textrun->addLink('http://test.com');
$textrun->addImage($localImage);
$textrun->addFootnote();
$textrun->addEndnote();
$textrun->addFootnote()->addText('Footnote');
$textrun->addEndnote()->addText('Endnote');
$section = $phpWord->addSection();

View File

@ -51,7 +51,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase
$phpWord->addFontStyle('Font', array('size' => 11));
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
$section = $phpWord->addSection();
$section = $phpWord->addSection(array('colsNum' => 2));
$section->addText($expected);
$section->addText('Test font style', 'Font');
$section->addText('Test paragraph style', null, 'Paragraph');
@ -60,14 +60,14 @@ class ContentTest extends \PHPUnit_Framework_TestCase
$section->addTextBreak();
$section->addPageBreak();
$section->addListItem('Test list item');
$section->addImage($imageSrc);
$section->addImage($imageSrc, array('width' => 50));
$section->addObject($objectSrc);
$section->addTOC();
$textrun = $section->addTextRun();
$textrun->addText('Test text run');
$table = $section->addTable();
$table = $section->addTable(array('width' => 50));
$cell = $table->addRow()->addCell();
$cell = $table->addRow()->addCell();
$cell->addText('Test');
@ -82,6 +82,8 @@ class ContentTest extends \PHPUnit_Framework_TestCase
$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";

View File

@ -28,7 +28,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
*/
public function testEmptyStyles()
{
$styles = array('Font', 'Paragraph');
$styles = array('Font', 'Paragraph', 'Image', 'Section', 'Table');
foreach ($styles as $style) {
$objectClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . $style;
$xmlWriter = new XMLWriter();