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

This commit is contained in:
Roman Syroeshko 2016-01-23 21:35:04 +04:00
parent ea4388def5
commit a621447993
4 changed files with 23 additions and 54 deletions

View File

@ -158,6 +158,8 @@ abstract class AbstractContainer extends AbstractElement
* Get all elements * Get all elements
* *
* @return array * @return array
*
* @codeCoverageIgnore
*/ */
public function getElements() public function getElements()
{ {

View File

@ -78,6 +78,8 @@ class Section extends AbstractContainer
* Get section style * Get section style
* *
* @return \PhpOffice\PhpWord\Style\Section * @return \PhpOffice\PhpWord\Style\Section
*
* @codeCoverageIgnore
*/ */
public function getStyle() public function getStyle()
{ {
@ -92,8 +94,6 @@ class Section extends AbstractContainer
* @param string $type * @param string $type
* *
* @return Header * @return Header
*
* @since 0.10.0
*/ */
public function addHeader($type = Header::AUTO) public function addHeader($type = Header::AUTO)
{ {
@ -108,8 +108,6 @@ class Section extends AbstractContainer
* @param string $type * @param string $type
* *
* @return Footer * @return Footer
*
* @since 0.10.0
*/ */
public function addFooter($type = Header::AUTO) public function addFooter($type = Header::AUTO)
{ {
@ -120,6 +118,8 @@ class Section extends AbstractContainer
* Get header elements * Get header elements
* *
* @return Header[] * @return Header[]
*
* @codeCoverageIgnore
*/ */
public function getHeaders() public function getHeaders()
{ {
@ -130,6 +130,8 @@ class Section extends AbstractContainer
* Get footer elements * Get footer elements
* *
* @return Footer[] * @return Footer[]
*
* @codeCoverageIgnore
*/ */
public function getFooters() public function getFooters()
{ {

View File

@ -17,55 +17,18 @@
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style;
/** /**
* Test class for PhpOffice\PhpWord\Element\Section * @covers \PhpOffice\PhpWord\Element\Section
* * @coversDefaultClass \PhpOffice\PhpWord\Element\Section
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class SectionTest extends \PHPUnit_Framework_TestCase class SectionTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* Get style * @covers ::setStyle
*/
public function testGetStyle()
{
$oSection = new Section(0);
$this->assertAttributeEquals($oSection->getStyle(), 'style', $oSection);
}
/**
* Get elements
*/
public function testGetElements()
{
$oSection = new Section(0);
$this->assertAttributeEquals($oSection->getElements(), 'elements', $oSection);
}
/**
* Get footer
*/
public function testGetFooters()
{
$oSection = new Section(0);
$this->assertAttributeEquals($oSection->getFooters(), 'footers', $oSection);
}
/**
* Get headers
*/
public function testGetHeaders()
{
$oSection = new Section(0);
$this->assertAttributeEquals($oSection->getHeaders(), 'headers', $oSection);
}
/**
* Set settings
*/ */
public function testSetStyle() public function testSetStyle()
{ {
@ -76,13 +39,12 @@ class SectionTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* Add elements * @coversNothing
*/ */
public function testAddElements() public function testAddElements()
{ {
$objectSource = __DIR__ . '/../_files/documents/reader.docx'; $objectSource = __DIR__ . '/../_files/documents/reader.docx';
$imageSource = __DIR__ . '/../_files/images/PhpWord.png'; $imageSource = __DIR__ . '/../_files/images/PhpWord.png';
// $imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif';
$section = new Section(0); $section = new Section(0);
$section->setPhpWord(new PhpWord()); $section->setPhpWord(new PhpWord());
@ -124,8 +86,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* Test add object exception * @coversNothing
*
* @expectedException \PhpOffice\PhpWord\Exception\InvalidObjectException * @expectedException \PhpOffice\PhpWord\Exception\InvalidObjectException
*/ */
public function testAddObjectException() public function testAddObjectException()
@ -137,6 +98,8 @@ class SectionTest extends \PHPUnit_Framework_TestCase
/** /**
* Add title with predefined style * Add title with predefined style
*
* @coversNothing
*/ */
public function testAddTitleWithStyle() public function testAddTitleWithStyle()
{ {
@ -150,7 +113,9 @@ class SectionTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* Add header footer * @covers ::addHeader
* @covers ::addFooter
* @covers ::hasDifferentFirstPage
*/ */
public function testAddHeaderFooter() public function testAddHeaderFooter()
{ {
@ -165,7 +130,8 @@ class SectionTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* Add header has different first page * @covers ::addHeader
* @covers ::hasDifferentFirstPage
*/ */
public function testHasDifferentFirstPage() public function testHasDifferentFirstPage()
{ {
@ -176,9 +142,8 @@ class SectionTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* Add header exception * @covers ::addHeader
* * @expectedException \Exception
* @expectedException Exception
* @expectedExceptionMessage Invalid header/footer type. * @expectedExceptionMessage Invalid header/footer type.
*/ */
public function testAddHeaderException() public function testAddHeaderException()

View File

@ -142,7 +142,7 @@ final class TemplateProcessorTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* @civers ::setValue * @covers ::setValue
* @covers ::cloneRow * @covers ::cloneRow
* @covers ::saveAs * @covers ::saveAs
* @test * @test