Skip to content

Commit 991016a

Browse files
committed
Additional writer test
1 parent a65c3c3 commit 991016a

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

src/PhpWord/Shared/String.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static function toUTF8($value = '')
8686
}
8787

8888
/**
89-
* Returns unicode array from UTF8 text
89+
* Returns unicode from UTF8 text
9090
*
9191
* The function is splitted to reduce cyclomatic complexity
9292
*
@@ -100,7 +100,7 @@ public static function toUnicode($text)
100100
}
101101

102102
/**
103-
* Returns unicode from UTF8 text
103+
* Returns unicode array from UTF8 text
104104
*
105105
* @param string $text UTF8 text
106106
* @return array

src/PhpWord/Writer/ODText/Part/Content.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,14 @@ private function writeAutoStyles(XMLWriter $xmlWriter)
115115
$xmlWriter->startElement('office:automatic-styles');
116116

117117
$this->writeTextStyles($xmlWriter);
118-
foreach ($this->autoStyles as $element => $style) {
118+
foreach ($this->autoStyles as $element => $styles) {
119119
$writerClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . $element;
120+
foreach ($styles as $style) {
120121

121-
/** @var \PhpOffice\PhpWord\Writer\ODText\Style\AbstractStyle $styleWriter Type hint */
122-
$styleWriter = new $writerClass($xmlWriter, $style);
123-
$styleWriter->write();
122+
/** @var \PhpOffice\PhpWord\Writer\ODText\Style\AbstractStyle $styleWriter Type hint */
123+
$styleWriter = new $writerClass($xmlWriter, $style);
124+
$styleWriter->write();
125+
}
124126
}
125127

126128
$xmlWriter->endElement(); // office:automatic-styles

tests/PhpWord/Tests/Writer/HTMLTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ public function testSave()
9292
$textrun = $section->addTextRun('Paragraph');
9393
$textrun->addLink('http://test.com');
9494
$textrun->addImage($localImage);
95-
$textrun->addFootnote();
96-
$textrun->addEndnote();
95+
$textrun->addFootnote()->addText('Footnote');
96+
$textrun->addEndnote()->addText('Endnote');
9797

9898
$section = $phpWord->addSection();
9999

tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testWriteContent()
5151
$phpWord->addFontStyle('Font', array('size' => 11));
5252
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
5353

54-
$section = $phpWord->addSection();
54+
$section = $phpWord->addSection(array('colsNum' => 2));
5555
$section->addText($expected);
5656
$section->addText('Test font style', 'Font');
5757
$section->addText('Test paragraph style', null, 'Paragraph');
@@ -60,14 +60,14 @@ public function testWriteContent()
6060
$section->addTextBreak();
6161
$section->addPageBreak();
6262
$section->addListItem('Test list item');
63-
$section->addImage($imageSrc);
63+
$section->addImage($imageSrc, array('width' => 50));
6464
$section->addObject($objectSrc);
6565
$section->addTOC();
6666

6767
$textrun = $section->addTextRun();
6868
$textrun->addText('Test text run');
6969

70-
$table = $section->addTable();
70+
$table = $section->addTable(array('width' => 50));
7171
$cell = $table->addRow()->addCell();
7272
$cell = $table->addRow()->addCell();
7373
$cell->addText('Test');
@@ -82,6 +82,8 @@ public function testWriteContent()
8282
$footer = $section->addFooter();
8383
$footer->addPreserveText('{PAGE}');
8484

85+
$table = $section->addTable('tblStyle')->addRow()->addCell();
86+
8587
$doc = TestHelperDOCX::getDocument($phpWord, 'ODText');
8688

8789
$element = "/office:document-content/office:body/office:text/text:section/text:p";

tests/PhpWord/Tests/Writer/ODText/StyleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
2828
*/
2929
public function testEmptyStyles()
3030
{
31-
$styles = array('Font', 'Paragraph');
31+
$styles = array('Font', 'Paragraph', 'Image', 'Section', 'Table');
3232
foreach ($styles as $style) {
3333
$objectClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . $style;
3434
$xmlWriter = new XMLWriter();

0 commit comments

Comments
 (0)