Skip to content

Commit 75a3fb8

Browse files
committed
Improve code coverage
1 parent 6657f0e commit 75a3fb8

File tree

5 files changed

+101
-1
lines changed

5 files changed

+101
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* This file is part of PHPWord - A pure PHP library for reading and writing
4+
* word processing documents.
5+
*
6+
* PHPWord is free software distributed under the terms of the GNU Lesser
7+
* General Public License version 3 as published by the Free Software Foundation.
8+
*
9+
* For the full copyright and license information, please read the LICENSE
10+
* file that was distributed with this source code. For the full list of
11+
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
12+
*
13+
* @see https://github.com/PHPOffice/PHPWord
14+
* @copyright 2010-2017 PHPWord contributors
15+
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16+
*/
17+
18+
namespace PhpOffice\PhpWord\Element;
19+
20+
/**
21+
* Test class for PhpOffice\PhpWord\Element\Footer
22+
*
23+
* @runTestsInSeparateProcesses
24+
*/
25+
class BookmarkTest extends \PHPUnit_Framework_TestCase
26+
{
27+
/**
28+
* New instance
29+
*/
30+
public function testConstruct()
31+
{
32+
$bookmarkName = 'test';
33+
$oBookmark = new Bookmark($bookmarkName);
34+
35+
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Bookmark', $oBookmark);
36+
$this->assertEquals($bookmarkName, $oBookmark->getName());
37+
}
38+
}

tests/PhpWord/Element/CommentTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,24 @@ public function testRelationId()
8080
$oComment->setRelationId($iVal);
8181
$this->assertEquals($iVal, $oComment->getRelationId());
8282
}
83+
84+
/**
85+
* @expectedException \InvalidArgumentException
86+
*/
87+
public function testExceptionOnCommentStartOnComment()
88+
{
89+
$dummyComment = new Comment('Test User', new \DateTime(), 'my_initials');
90+
$oComment = new Comment('Test User', new \DateTime(), 'my_initials');
91+
$oComment->setCommentRangeStart($dummyComment);
92+
}
93+
94+
/**
95+
* @expectedException \InvalidArgumentException
96+
*/
97+
public function testExceptionOnCommentEndOnComment()
98+
{
99+
$dummyComment = new Comment('Test User', new \DateTime(), 'my_initials');
100+
$oComment = new Comment('Test User', new \DateTime(), 'my_initials');
101+
$oComment->setCommentRangeEnd($dummyComment);
102+
}
83103
}

tests/PhpWord/Element/ObjectTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,22 @@
2626
class ObjectTest extends \PHPUnit_Framework_TestCase
2727
{
2828
/**
29-
* Create new instance with supported files
29+
* Create new instance with supported files, 4 character extention
3030
*/
3131
public function testConstructWithSupportedFiles()
32+
{
33+
$src = __DIR__ . '/../_files/documents/reader.docx';
34+
$oObject = new Object($src);
35+
36+
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Object', $oObject);
37+
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oObject->getStyle());
38+
$this->assertEquals($src, $oObject->getSource());
39+
}
40+
41+
/**
42+
* Create new instance with supported files
43+
*/
44+
public function testConstructWithSupportedFilesLong()
3245
{
3346
$src = __DIR__ . '/../_files/documents/sheet.xls';
3447
$oObject = new Object($src);

tests/PhpWord/Element/SectionTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ public function testAddHeaderFooter()
129129
$this->assertFalse($object->hasDifferentFirstPage());
130130
}
131131

132+
/**
133+
* @covers ::addHeader
134+
* @covers ::hasDifferentFirstPage
135+
*/
136+
public function testHasDifferentFirstPageFooter()
137+
{
138+
$object = new Section(1);
139+
$object->addFooter(Header::FIRST);
140+
$this->assertTrue($object->hasDifferentFirstPage());
141+
}
142+
132143
/**
133144
* @covers ::addHeader
134145
* @covers ::hasDifferentFirstPage

tests/PhpWord/Metadata/SettingsTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,24 @@ public function testProofState()
116116
$this->assertEquals(ProofState::DIRTY, $oSettings->getProofState()->getSpelling());
117117
}
118118

119+
/**
120+
* @expectedException \InvalidArgumentException
121+
*/
122+
public function testWrongProofStateGrammar()
123+
{
124+
$proofState = new ProofState();
125+
$proofState->setGrammar('wrong');
126+
}
127+
128+
/**
129+
* @expectedException \InvalidArgumentException
130+
*/
131+
public function testWrongProofStateSpelling()
132+
{
133+
$proofState = new ProofState();
134+
$proofState->setSpelling('wrong');
135+
}
136+
119137
/**
120138
* Zoom as percentage
121139
*/

0 commit comments

Comments
 (0)