diff --git a/Classes/PHPWord/Section/TextRun.php b/Classes/PHPWord/Section/TextRun.php index d6ec7321..c26b2ef6 100755 --- a/Classes/PHPWord/Section/TextRun.php +++ b/Classes/PHPWord/Section/TextRun.php @@ -136,7 +136,8 @@ class PHPWord_Section_TextRun * * @param int $count */ - public function addTextBreak($count = 1) { + public function addTextBreak($count = 1) + { for ($i=1; $i<=$count; $i++) { $this->_elementCollection[] = new PHPWord_Section_TextBreak(); } diff --git a/Tests/PHPWord/Reader/Word2007.php b/Tests/PHPWord/Reader/Word2007Test.php similarity index 100% rename from Tests/PHPWord/Reader/Word2007.php rename to Tests/PHPWord/Reader/Word2007Test.php diff --git a/Tests/PHPWord/TOCTest.php b/Tests/PHPWord/TOCTest.php new file mode 100644 index 00000000..74038ee3 --- /dev/null +++ b/Tests/PHPWord/TOCTest.php @@ -0,0 +1,72 @@ + 9062, + 'tabLeader' => PHPWord_Style_TOC::TABLEADER_DOT, + 'indent' => 200, + ); + $object = new PHPWord_TOC( + array('size' => 11), + array('tabPos' => $expected['tabPos']) + ); + $tocStyle = $object->getStyleTOC(); + + $this->assertInstanceOf('PHPWord_Style_TOC', $tocStyle); + $this->assertInstanceOf('PHPWord_Style_Font', $object->getStyleFont()); + + foreach ($expected as $key => $value) { + $method = "get{$key}"; + $this->assertEquals($value, $tocStyle->$method()); + } + } + + /** + * @covers PHPWord_TOC::addTitle + * @covers PHPWord_TOC::getTitles + */ + public function testAddAndGetTitle() + { + // Prepare variables + $titleCount = 3; + $anchor = '_Toc' . (252634154 + $titleCount); + $bookmark = $titleCount - 1; // zero based + $titles = array( + 'Heading 1' => 1, + 'Heading 2' => 2, + 'Heading 3' => 3, + ); + + // @covers PHPWord_TOC::addTitle + foreach ($titles as $text => $depth) { + $response = PHPWord_TOC::addTitle($text, $depth); + } + $this->assertEquals($anchor, $response[0]); + $this->assertEquals($bookmark, $response[1]); + + // @covers PHPWord_TOC::getTitles + $i = 0; + $savedTitles = PHPWord_TOC::getTitles(); + foreach ($titles as $text => $depth) { + $this->assertEquals($text, $savedTitles[$i]['text']); + $this->assertEquals($depth, $savedTitles[$i]['depth']); + $i++; + } + } +}