Skip to content

Commit a621447

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

File tree

4 files changed

+23
-54
lines changed

4 files changed

+23
-54
lines changed

src/PhpWord/Element/AbstractContainer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ protected function addElement($elementName)
158158
* Get all elements
159159
*
160160
* @return array
161+
*
162+
* @codeCoverageIgnore
161163
*/
162164
public function getElements()
163165
{

src/PhpWord/Element/Section.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public function setStyle($style = null)
7878
* Get section style
7979
*
8080
* @return \PhpOffice\PhpWord\Style\Section
81+
*
82+
* @codeCoverageIgnore
8183
*/
8284
public function getStyle()
8385
{
@@ -92,8 +94,6 @@ public function getStyle()
9294
* @param string $type
9395
*
9496
* @return Header
95-
*
96-
* @since 0.10.0
9797
*/
9898
public function addHeader($type = Header::AUTO)
9999
{
@@ -108,8 +108,6 @@ public function addHeader($type = Header::AUTO)
108108
* @param string $type
109109
*
110110
* @return Footer
111-
*
112-
* @since 0.10.0
113111
*/
114112
public function addFooter($type = Header::AUTO)
115113
{
@@ -120,6 +118,8 @@ public function addFooter($type = Header::AUTO)
120118
* Get header elements
121119
*
122120
* @return Header[]
121+
*
122+
* @codeCoverageIgnore
123123
*/
124124
public function getHeaders()
125125
{
@@ -130,6 +130,8 @@ public function getHeaders()
130130
* Get footer elements
131131
*
132132
* @return Footer[]
133+
*
134+
* @codeCoverageIgnore
133135
*/
134136
public function getFooters()
135137
{

tests/PhpWord/Element/SectionTest.php

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,18 @@
1717

1818
namespace PhpOffice\PhpWord\Element;
1919

20-
use PhpOffice\PhpWord\Exception\Exception;
2120
use PhpOffice\PhpWord\PhpWord;
2221
use PhpOffice\PhpWord\Style;
2322

2423
/**
25-
* Test class for PhpOffice\PhpWord\Element\Section
26-
*
24+
* @covers \PhpOffice\PhpWord\Element\Section
25+
* @coversDefaultClass \PhpOffice\PhpWord\Element\Section
2726
* @runTestsInSeparateProcesses
2827
*/
2928
class SectionTest extends \PHPUnit_Framework_TestCase
3029
{
3130
/**
32-
* Get style
33-
*/
34-
public function testGetStyle()
35-
{
36-
$oSection = new Section(0);
37-
$this->assertAttributeEquals($oSection->getStyle(), 'style', $oSection);
38-
}
39-
40-
/**
41-
* Get elements
42-
*/
43-
public function testGetElements()
44-
{
45-
$oSection = new Section(0);
46-
$this->assertAttributeEquals($oSection->getElements(), 'elements', $oSection);
47-
}
48-
49-
/**
50-
* Get footer
51-
*/
52-
public function testGetFooters()
53-
{
54-
$oSection = new Section(0);
55-
$this->assertAttributeEquals($oSection->getFooters(), 'footers', $oSection);
56-
}
57-
58-
/**
59-
* Get headers
60-
*/
61-
public function testGetHeaders()
62-
{
63-
$oSection = new Section(0);
64-
$this->assertAttributeEquals($oSection->getHeaders(), 'headers', $oSection);
65-
}
66-
67-
/**
68-
* Set settings
31+
* @covers ::setStyle
6932
*/
7033
public function testSetStyle()
7134
{
@@ -76,13 +39,12 @@ public function testSetStyle()
7639
}
7740

7841
/**
79-
* Add elements
42+
* @coversNothing
8043
*/
8144
public function testAddElements()
8245
{
8346
$objectSource = __DIR__ . '/../_files/documents/reader.docx';
8447
$imageSource = __DIR__ . '/../_files/images/PhpWord.png';
85-
// $imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif';
8648

8749
$section = new Section(0);
8850
$section->setPhpWord(new PhpWord());
@@ -124,8 +86,7 @@ public function testAddElements()
12486
}
12587

12688
/**
127-
* Test add object exception
128-
*
89+
* @coversNothing
12990
* @expectedException \PhpOffice\PhpWord\Exception\InvalidObjectException
13091
*/
13192
public function testAddObjectException()
@@ -137,6 +98,8 @@ public function testAddObjectException()
13798

13899
/**
139100
* Add title with predefined style
101+
*
102+
* @coversNothing
140103
*/
141104
public function testAddTitleWithStyle()
142105
{
@@ -150,7 +113,9 @@ public function testAddTitleWithStyle()
150113
}
151114

152115
/**
153-
* Add header footer
116+
* @covers ::addHeader
117+
* @covers ::addFooter
118+
* @covers ::hasDifferentFirstPage
154119
*/
155120
public function testAddHeaderFooter()
156121
{
@@ -165,7 +130,8 @@ public function testAddHeaderFooter()
165130
}
166131

167132
/**
168-
* Add header has different first page
133+
* @covers ::addHeader
134+
* @covers ::hasDifferentFirstPage
169135
*/
170136
public function testHasDifferentFirstPage()
171137
{
@@ -176,9 +142,8 @@ public function testHasDifferentFirstPage()
176142
}
177143

178144
/**
179-
* Add header exception
180-
*
181-
* @expectedException Exception
145+
* @covers ::addHeader
146+
* @expectedException \Exception
182147
* @expectedExceptionMessage Invalid header/footer type.
183148
*/
184149
public function testAddHeaderException()

tests/PhpWord/TemplateProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromT
142142
}
143143

144144
/**
145-
* @civers ::setValue
145+
* @covers ::setValue
146146
* @covers ::cloneRow
147147
* @covers ::saveAs
148148
* @test

0 commit comments

Comments
 (0)