Improved coverage for \PhpOffice\PhpWord\Element\Section (#665).
This commit is contained in:
parent
3981e01489
commit
ea4388def5
@ -17,12 +17,8 @@
|
|||||||
|
|
||||||
namespace PhpOffice\PhpWord\Element;
|
namespace PhpOffice\PhpWord\Element;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Exception\Exception;
|
|
||||||
use PhpOffice\PhpWord\Style\Section as SectionStyle;
|
use PhpOffice\PhpWord\Style\Section as SectionStyle;
|
||||||
|
|
||||||
/**
|
|
||||||
* Section
|
|
||||||
*/
|
|
||||||
class Section extends AbstractContainer
|
class Section extends AbstractContainer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -91,8 +87,12 @@ class Section extends AbstractContainer
|
|||||||
/**
|
/**
|
||||||
* Add header
|
* Add header
|
||||||
*
|
*
|
||||||
|
* @since 0.10.0
|
||||||
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
|
*
|
||||||
* @return Header
|
* @return Header
|
||||||
|
*
|
||||||
* @since 0.10.0
|
* @since 0.10.0
|
||||||
*/
|
*/
|
||||||
public function addHeader($type = Header::AUTO)
|
public function addHeader($type = Header::AUTO)
|
||||||
@ -103,8 +103,12 @@ class Section extends AbstractContainer
|
|||||||
/**
|
/**
|
||||||
* Add footer
|
* Add footer
|
||||||
*
|
*
|
||||||
|
* @since 0.10.0
|
||||||
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
|
*
|
||||||
* @return Footer
|
* @return Footer
|
||||||
|
*
|
||||||
* @since 0.10.0
|
* @since 0.10.0
|
||||||
*/
|
*/
|
||||||
public function addFooter($type = Header::AUTO)
|
public function addFooter($type = Header::AUTO)
|
||||||
@ -160,7 +164,7 @@ class Section extends AbstractContainer
|
|||||||
*
|
*
|
||||||
* @return Header|Footer
|
* @return Header|Footer
|
||||||
*
|
*
|
||||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
private function addHeaderFooter($type = Header::AUTO, $header = true)
|
private function addHeaderFooter($type = Header::AUTO, $header = true)
|
||||||
{
|
{
|
||||||
@ -178,7 +182,7 @@ class Section extends AbstractContainer
|
|||||||
$collection[$index] = $container;
|
$collection[$index] = $container;
|
||||||
return $container;
|
return $container;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Invalid header/footer type.');
|
throw new \Exception('Invalid header/footer type.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
$object = new Section(0);
|
||||||
$elements = array('Header', 'Footer');
|
$elements = array('Header', 'Footer');
|
||||||
|
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
$method = "create{$element}";
|
$method = "add{$element}";
|
||||||
$this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$element}", $object->$method());
|
$this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$element}", $object->$method());
|
||||||
}
|
}
|
||||||
$this->assertFalse($object->hasDifferentFirstPage());
|
$this->assertFalse($object->hasDifferentFirstPage());
|
||||||
@ -179,7 +179,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
|
|||||||
* Add header exception
|
* Add header exception
|
||||||
*
|
*
|
||||||
* @expectedException Exception
|
* @expectedException Exception
|
||||||
* @expectedExceptionMesssage Invalid header/footer type.
|
* @expectedExceptionMessage Invalid header/footer type.
|
||||||
*/
|
*/
|
||||||
public function testAddHeaderException()
|
public function testAddHeaderException()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user