Improved coverage for `\PhpOffice\PhpWord\Element\Section` (#665).

This commit is contained in:
Roman Syroeshko 2016-01-23 21:06:09 +04:00
parent 3981e01489
commit ea4388def5
2 changed files with 14 additions and 10 deletions

View File

@ -17,12 +17,8 @@
namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Style\Section as SectionStyle;
/**
* Section
*/
class Section extends AbstractContainer
{
/**
@ -91,8 +87,12 @@ class Section extends AbstractContainer
/**
* Add header
*
* @since 0.10.0
*
* @param string $type
*
* @return Header
*
* @since 0.10.0
*/
public function addHeader($type = Header::AUTO)
@ -103,8 +103,12 @@ class Section extends AbstractContainer
/**
* Add footer
*
* @since 0.10.0
*
* @param string $type
*
* @return Footer
*
* @since 0.10.0
*/
public function addFooter($type = Header::AUTO)
@ -160,7 +164,7 @@ class Section extends AbstractContainer
*
* @return Header|Footer
*
* @throws \PhpOffice\PhpWord\Exception\Exception
* @throws \Exception
*/
private function addHeaderFooter($type = Header::AUTO, $header = true)
{
@ -178,7 +182,7 @@ class Section extends AbstractContainer
$collection[$index] = $container;
return $container;
} else {
throw new Exception('Invalid header/footer type.');
throw new \Exception('Invalid header/footer type.');
}
}

View File

@ -150,15 +150,15 @@ class SectionTest extends \PHPUnit_Framework_TestCase
}
/**
* Create header footer
* Add header footer
*/
public function testCreateHeaderFooter()
public function testAddHeaderFooter()
{
$object = new Section(0);
$elements = array('Header', 'Footer');
foreach ($elements as $element) {
$method = "create{$element}";
$method = "add{$element}";
$this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$element}", $object->$method());
}
$this->assertFalse($object->hasDifferentFirstPage());
@ -179,7 +179,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
* Add header exception
*
* @expectedException Exception
* @expectedExceptionMesssage Invalid header/footer type.
* @expectedExceptionMessage Invalid header/footer type.
*/
public function testAddHeaderException()
{