Improve code coverage

This commit is contained in:
troosan 2017-09-27 00:27:33 +02:00
parent 6657f0eec3
commit 75a3fb8e40
5 changed files with 101 additions and 1 deletions

View File

@ -0,0 +1,38 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
* @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Element;
/**
* Test class for PhpOffice\PhpWord\Element\Footer
*
* @runTestsInSeparateProcesses
*/
class BookmarkTest extends \PHPUnit_Framework_TestCase
{
/**
* New instance
*/
public function testConstruct()
{
$bookmarkName = 'test';
$oBookmark = new Bookmark($bookmarkName);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Bookmark', $oBookmark);
$this->assertEquals($bookmarkName, $oBookmark->getName());
}
}

View File

@ -80,4 +80,24 @@ class CommentTest extends \PHPUnit_Framework_TestCase
$oComment->setRelationId($iVal);
$this->assertEquals($iVal, $oComment->getRelationId());
}
/**
* @expectedException \InvalidArgumentException
*/
public function testExceptionOnCommentStartOnComment()
{
$dummyComment = new Comment('Test User', new \DateTime(), 'my_initials');
$oComment = new Comment('Test User', new \DateTime(), 'my_initials');
$oComment->setCommentRangeStart($dummyComment);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testExceptionOnCommentEndOnComment()
{
$dummyComment = new Comment('Test User', new \DateTime(), 'my_initials');
$oComment = new Comment('Test User', new \DateTime(), 'my_initials');
$oComment->setCommentRangeEnd($dummyComment);
}
}

View File

@ -26,9 +26,22 @@ namespace PhpOffice\PhpWord\Element;
class ObjectTest extends \PHPUnit_Framework_TestCase
{
/**
* Create new instance with supported files
* Create new instance with supported files, 4 character extention
*/
public function testConstructWithSupportedFiles()
{
$src = __DIR__ . '/../_files/documents/reader.docx';
$oObject = new Object($src);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Object', $oObject);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oObject->getStyle());
$this->assertEquals($src, $oObject->getSource());
}
/**
* Create new instance with supported files
*/
public function testConstructWithSupportedFilesLong()
{
$src = __DIR__ . '/../_files/documents/sheet.xls';
$oObject = new Object($src);

View File

@ -129,6 +129,17 @@ class SectionTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($object->hasDifferentFirstPage());
}
/**
* @covers ::addHeader
* @covers ::hasDifferentFirstPage
*/
public function testHasDifferentFirstPageFooter()
{
$object = new Section(1);
$object->addFooter(Header::FIRST);
$this->assertTrue($object->hasDifferentFirstPage());
}
/**
* @covers ::addHeader
* @covers ::hasDifferentFirstPage

View File

@ -116,6 +116,24 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(ProofState::DIRTY, $oSettings->getProofState()->getSpelling());
}
/**
* @expectedException \InvalidArgumentException
*/
public function testWrongProofStateGrammar()
{
$proofState = new ProofState();
$proofState->setGrammar('wrong');
}
/**
* @expectedException \InvalidArgumentException
*/
public function testWrongProofStateSpelling()
{
$proofState = new ProofState();
$proofState->setSpelling('wrong');
}
/**
* Zoom as percentage
*/