Skip to content

Commit ea4388d

Browse files
author
Roman Syroeshko
committed
Improved coverage for \PhpOffice\PhpWord\Element\Section (#665).
1 parent 3981e01 commit ea4388d

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/PhpWord/Element/Section.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@
1717

1818
namespace PhpOffice\PhpWord\Element;
1919

20-
use PhpOffice\PhpWord\Exception\Exception;
2120
use PhpOffice\PhpWord\Style\Section as SectionStyle;
2221

23-
/**
24-
* Section
25-
*/
2622
class Section extends AbstractContainer
2723
{
2824
/**
@@ -91,8 +87,12 @@ public function getStyle()
9187
/**
9288
* Add header
9389
*
90+
* @since 0.10.0
91+
*
9492
* @param string $type
93+
*
9594
* @return Header
95+
*
9696
* @since 0.10.0
9797
*/
9898
public function addHeader($type = Header::AUTO)
@@ -103,8 +103,12 @@ public function addHeader($type = Header::AUTO)
103103
/**
104104
* Add footer
105105
*
106+
* @since 0.10.0
107+
*
106108
* @param string $type
109+
*
107110
* @return Footer
111+
*
108112
* @since 0.10.0
109113
*/
110114
public function addFooter($type = Header::AUTO)
@@ -160,7 +164,7 @@ public function hasDifferentFirstPage()
160164
*
161165
* @return Header|Footer
162166
*
163-
* @throws \PhpOffice\PhpWord\Exception\Exception
167+
* @throws \Exception
164168
*/
165169
private function addHeaderFooter($type = Header::AUTO, $header = true)
166170
{
@@ -178,7 +182,7 @@ private function addHeaderFooter($type = Header::AUTO, $header = true)
178182
$collection[$index] = $container;
179183
return $container;
180184
} else {
181-
throw new Exception('Invalid header/footer type.');
185+
throw new \Exception('Invalid header/footer type.');
182186
}
183187

184188
}

tests/PhpWord/Element/SectionTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ public function testAddTitleWithStyle()
150150
}
151151

152152
/**
153-
* Create header footer
153+
* Add header footer
154154
*/
155-
public function testCreateHeaderFooter()
155+
public function testAddHeaderFooter()
156156
{
157157
$object = new Section(0);
158158
$elements = array('Header', 'Footer');
159159

160160
foreach ($elements as $element) {
161-
$method = "create{$element}";
161+
$method = "add{$element}";
162162
$this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$element}", $object->$method());
163163
}
164164
$this->assertFalse($object->hasDifferentFirstPage());
@@ -179,7 +179,7 @@ public function testHasDifferentFirstPage()
179179
* Add header exception
180180
*
181181
* @expectedException Exception
182-
* @expectedExceptionMesssage Invalid header/footer type.
182+
* @expectedExceptionMessage Invalid header/footer type.
183183
*/
184184
public function testAddHeaderException()
185185
{

0 commit comments

Comments
 (0)