Unit tests enhancement
This commit is contained in:
parent
2d178a6724
commit
7a424318d2
@ -436,13 +436,14 @@ class DocumentProperties
|
||||
*/
|
||||
public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null)
|
||||
{
|
||||
if (($propertyType === null) || (!in_array($propertyType, array(
|
||||
$propertyTypes = array(
|
||||
self::PROPERTY_TYPE_INTEGER,
|
||||
self::PROPERTY_TYPE_FLOAT,
|
||||
self::PROPERTY_TYPE_STRING,
|
||||
self::PROPERTY_TYPE_DATE,
|
||||
self::PROPERTY_TYPE_BOOLEAN
|
||||
)))) {
|
||||
);
|
||||
if (($propertyType === null) || (!in_array($propertyType, $propertyTypes))) {
|
||||
if ($propertyValue === null) {
|
||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||
} elseif (is_float($propertyValue)) {
|
||||
|
||||
@ -31,10 +31,7 @@ class Footnote
|
||||
/**
|
||||
* Add new Footnote Element
|
||||
*
|
||||
* @param string $linkSrc
|
||||
* @param string $linkName
|
||||
*
|
||||
* @return mixed
|
||||
* @return int Reference ID
|
||||
*/
|
||||
public static function addFootnoteElement(\PhpOffice\PhpWord\Section\Footnote $footnote)
|
||||
{
|
||||
@ -70,7 +67,7 @@ class Footnote
|
||||
*
|
||||
* @param string $linkSrc
|
||||
*
|
||||
* @return mixed
|
||||
* @return int Reference ID
|
||||
*/
|
||||
public static function addFootnoteLinkElement($linkSrc)
|
||||
{
|
||||
|
||||
@ -69,11 +69,10 @@ class Media
|
||||
$file = null;
|
||||
if ($type === 'image') {
|
||||
$cImg++;
|
||||
$isMemImage = false;
|
||||
if (!is_null($image)) {
|
||||
$isMemImage = $image->getIsMemImage();
|
||||
$extension = $image->getImageExtension();
|
||||
} else {
|
||||
$isMemImage = false;
|
||||
}
|
||||
if ($isMemImage) {
|
||||
$media['isMemImage'] = true;
|
||||
@ -181,11 +180,10 @@ class Media
|
||||
$rID = $cImg + 1;
|
||||
$cImg++;
|
||||
$media = array();
|
||||
$isMemImage = false;
|
||||
if (!is_null($image)) {
|
||||
$isMemImage = $image->getIsMemImage();
|
||||
$extension = $image->getImageExtension();
|
||||
} else {
|
||||
$isMemImage = false;
|
||||
}
|
||||
if ($isMemImage) {
|
||||
$media['isMemImage'] = true;
|
||||
@ -244,11 +242,10 @@ class Media
|
||||
$cImg = self::countFooterMediaElements($key);
|
||||
$rID = $cImg + 1;
|
||||
$cImg++;
|
||||
$isMemImage = false;
|
||||
if (!is_null($image)) {
|
||||
$isMemImage = $image->getIsMemImage();
|
||||
$extension = $image->getImageExtension();
|
||||
} else {
|
||||
$isMemImage = false;
|
||||
}
|
||||
if ($isMemImage) {
|
||||
$media['isMemImage'] = true;
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
|
||||
namespace PhpOffice\PhpWord;
|
||||
|
||||
use PhpOffice\PhpWord\Exceptions\InvalidImageException;
|
||||
use PhpOffice\PhpWord\Exceptions\InvalidObjectException;
|
||||
use PhpOffice\PhpWord\Section\Footer;
|
||||
use PhpOffice\PhpWord\Section\Image;
|
||||
@ -211,72 +210,61 @@ class Section
|
||||
/**
|
||||
* Add a OLE-Object Element
|
||||
*
|
||||
* All exceptions should be handled by PhpOffice\PhpWord\Section\Object
|
||||
*
|
||||
* @param string $src
|
||||
* @param mixed $style
|
||||
* @return \PhpOffice\PhpWord\Section\Object
|
||||
* @throws \PhpOffice\PhpWord\Exceptions\InvalidObjectException
|
||||
*/
|
||||
public function addObject($src, $style = null)
|
||||
{
|
||||
$object = new Object($src, $style);
|
||||
|
||||
if (!is_null($object->getSource())) {
|
||||
$inf = pathinfo($src);
|
||||
$ext = $inf['extension'];
|
||||
if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') {
|
||||
$ext = substr($ext, 0, -1);
|
||||
}
|
||||
|
||||
$iconSrc = __DIR__ . '/_staticDocParts/';
|
||||
if (!\file_exists($iconSrc . '_' . $ext . '.png')) {
|
||||
$iconSrc = $iconSrc . '_default.png';
|
||||
} else {
|
||||
$iconSrc .= '_' . $ext . '.png';
|
||||
}
|
||||
|
||||
$rIDimg = Media::addSectionMediaElement($iconSrc, 'image', new Image($iconSrc));
|
||||
$icon = __DIR__ . "/_staticDocParts/_{$ext}.png";
|
||||
$rIDimg = Media::addSectionMediaElement($icon, 'image', new Image($icon));
|
||||
$data = Media::addSectionMediaElement($src, 'oleObject');
|
||||
$rID = $data[0];
|
||||
$objectId = $data[1];
|
||||
|
||||
$object->setRelationId($rID);
|
||||
$object->setObjectId($objectId);
|
||||
$object->setImageRelationId($rIDimg);
|
||||
|
||||
$this->_elementCollection[] = $object;
|
||||
return $object;
|
||||
} else {
|
||||
throw new InvalidObjectException;
|
||||
throw new InvalidObjectException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Image Element
|
||||
* Add image element
|
||||
*
|
||||
* All exceptions should be handled by PhpOffice\PhpWord\Section\Image
|
||||
*
|
||||
* @param string $src
|
||||
* @param mixed $style
|
||||
* @return \PhpOffice\PhpWord\Section\Image
|
||||
* @throws \PhpOffice\PhpWord\Exceptions\InvalidImageException
|
||||
*/
|
||||
public function addImage($src, $style = null)
|
||||
{
|
||||
$image = new Image($src, $style);
|
||||
if (!is_null($image->getSource())) {
|
||||
$rID = Media::addSectionMediaElement($src, 'image', $image);
|
||||
$image->setRelationId($rID);
|
||||
$this->_elementCollection[] = $image;
|
||||
return $image;
|
||||
} else {
|
||||
throw new InvalidImageException;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a by PHP created Image Element
|
||||
* Add memory image element
|
||||
*
|
||||
* @param string $link
|
||||
* @param mixed $style
|
||||
* @deprecated
|
||||
*
|
||||
* @param string $src
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function addMemoryImage($src, $style = null)
|
||||
{
|
||||
|
||||
@ -131,7 +131,7 @@ class Footer
|
||||
/**
|
||||
* Add a by PHP created Image Element
|
||||
*
|
||||
* @param string $link
|
||||
* @param string $src
|
||||
* @param mixed $style
|
||||
* @deprecated
|
||||
*/
|
||||
|
||||
@ -160,7 +160,7 @@ class Header
|
||||
/**
|
||||
* Add a by PHP created Image Element
|
||||
*
|
||||
* @param string $link
|
||||
* @param string $src
|
||||
* @param mixed $style
|
||||
* @deprecated
|
||||
*/
|
||||
|
||||
@ -58,7 +58,7 @@ class Object
|
||||
*/
|
||||
public function __construct($src, $style = null)
|
||||
{
|
||||
$_supportedObjectTypes = array('xls', 'doc', 'ppt');
|
||||
$_supportedObjectTypes = array('xls', 'doc', 'ppt', 'xlsx', 'docx', 'pptx');
|
||||
$inf = pathinfo($src);
|
||||
|
||||
if (\file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) {
|
||||
|
||||
@ -205,7 +205,7 @@ class Cell
|
||||
/**
|
||||
* Add a by PHP created Image Element
|
||||
*
|
||||
* @param string $link
|
||||
* @param string $src
|
||||
* @param mixed $style
|
||||
* @deprecated
|
||||
*/
|
||||
|
||||
@ -11,9 +11,11 @@ namespace PhpOffice\PhpWord\Shared;
|
||||
|
||||
use PhpOffice\PhpWord\Settings;
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
if (!defined('DATE_W3C')) {
|
||||
define('DATE_W3C', 'Y-m-d\TH:i:sP');
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
/**
|
||||
* XMLWriter wrapper
|
||||
|
||||
@ -208,16 +208,6 @@ class Table
|
||||
return $this->_firstRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Last Row Style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Table
|
||||
*/
|
||||
public function getLastRow()
|
||||
{
|
||||
return $this->_lastRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get background
|
||||
*
|
||||
|
||||
@ -17,37 +17,37 @@ use PhpOffice\PhpWord\Style\Font;
|
||||
class TOC
|
||||
{
|
||||
/**
|
||||
* Title Elements
|
||||
* Title elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_titles = array();
|
||||
|
||||
/**
|
||||
* TOC Style
|
||||
* TOC style
|
||||
*
|
||||
* @var array
|
||||
* @var PhpOffice\PhpWord\Style\TOC
|
||||
*/
|
||||
private static $_styleTOC;
|
||||
|
||||
/**
|
||||
* Font Style
|
||||
* Font style
|
||||
*
|
||||
* @var array
|
||||
* @var PhpOffice\PhpWord\Style\Font|array|string
|
||||
*/
|
||||
private static $_styleFont;
|
||||
|
||||
/**
|
||||
* Title Anchor
|
||||
* Title anchor
|
||||
*
|
||||
* @var array
|
||||
* @var int
|
||||
*/
|
||||
private static $_anchor = 252634154;
|
||||
|
||||
/**
|
||||
* Title Bookmark
|
||||
* Title bookmark
|
||||
*
|
||||
* @var array
|
||||
* @var int
|
||||
*/
|
||||
private static $_bookmarkId = 0;
|
||||
|
||||
@ -55,7 +55,7 @@ class TOC
|
||||
/**
|
||||
* Create a new Table-of-Contents Element
|
||||
*
|
||||
* @param array $styleFont
|
||||
* @param mixed $styleFont
|
||||
* @param array $styleTOC
|
||||
*/
|
||||
public function __construct($styleFont = null, $styleTOC = null)
|
||||
@ -74,7 +74,6 @@ class TOC
|
||||
if (!is_null($styleFont)) {
|
||||
if (is_array($styleFont)) {
|
||||
self::$_styleFont = new Font();
|
||||
|
||||
foreach ($styleFont as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
|
||||
@ -14,11 +14,13 @@ use PhpOffice\PhpWord\Autoloader;
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Autoloader
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Autoloader
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class AutoloaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Register
|
||||
*/
|
||||
public function testRegister()
|
||||
{
|
||||
Autoloader::register();
|
||||
@ -28,6 +30,9 @@ class AutoloaderTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoload
|
||||
*/
|
||||
public function testAutoload()
|
||||
{
|
||||
$declared = \get_declared_classes();
|
||||
|
||||
@ -14,11 +14,13 @@ use PhpOffice\PhpWord\DocumentProperties;
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\DocumentProperties
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\DocumentProperties
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Creator
|
||||
*/
|
||||
public function testCreator()
|
||||
{
|
||||
$oProperties = new DocumentProperties();
|
||||
@ -29,6 +31,9 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('AAA', $oProperties->getCreator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Last modified by
|
||||
*/
|
||||
public function testLastModifiedBy()
|
||||
{
|
||||
$oProperties = new DocumentProperties();
|
||||
@ -39,6 +44,9 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('AAA', $oProperties->getLastModifiedBy());
|
||||
}
|
||||
|
||||
/**
|
||||
* Created
|
||||
*/
|
||||
public function testCreated()
|
||||
{
|
||||
$oProperties = new DocumentProperties();
|
||||
@ -50,6 +58,9 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($iTime, $oProperties->getCreated());
|
||||
}
|
||||
|
||||
/**
|
||||
* Modified
|
||||
*/
|
||||
public function testModified()
|
||||
{
|
||||
$oProperties = new DocumentProperties();
|
||||
@ -61,6 +72,9 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($iTime, $oProperties->getModified());
|
||||
}
|
||||
|
||||
/**
|
||||
* Title
|
||||
*/
|
||||
public function testTitle()
|
||||
{
|
||||
$oProperties = new DocumentProperties();
|
||||
@ -71,6 +85,9 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('AAA', $oProperties->getTitle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Description
|
||||
*/
|
||||
public function testDescription()
|
||||
{
|
||||
$oProperties = new DocumentProperties();
|
||||
@ -81,6 +98,9 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('AAA', $oProperties->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Subject
|
||||
*/
|
||||
public function testSubject()
|
||||
{
|
||||
$oProperties = new DocumentProperties();
|
||||
@ -91,6 +111,9 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('AAA', $oProperties->getSubject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Keywords
|
||||
*/
|
||||
public function testKeywords()
|
||||
{
|
||||
$oProperties = new DocumentProperties();
|
||||
@ -101,6 +124,9 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('AAA', $oProperties->getKeywords());
|
||||
}
|
||||
|
||||
/**
|
||||
* Category
|
||||
*/
|
||||
public function testCategory()
|
||||
{
|
||||
$oProperties = new DocumentProperties();
|
||||
@ -111,6 +137,9 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('AAA', $oProperties->getCategory());
|
||||
}
|
||||
|
||||
/**
|
||||
* Company
|
||||
*/
|
||||
public function testCompany()
|
||||
{
|
||||
$oProperties = new DocumentProperties();
|
||||
@ -121,6 +150,9 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('AAA', $oProperties->getCompany());
|
||||
}
|
||||
|
||||
/**
|
||||
* Manager
|
||||
*/
|
||||
public function testManager()
|
||||
{
|
||||
$oProperties = new DocumentProperties();
|
||||
@ -131,6 +163,9 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('AAA', $oProperties->getManager());
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom properties
|
||||
*/
|
||||
public function testCustomProperty()
|
||||
{
|
||||
$oProperties = new DocumentProperties();
|
||||
@ -177,6 +212,9 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
), $oProperties->getCustomProperties());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert property
|
||||
*/
|
||||
public function testConvertProperty()
|
||||
{
|
||||
$this->assertEquals('', DocumentProperties::convertProperty('a', 'empty'));
|
||||
|
||||
35
tests/PhpWord/Tests/FootnoteTest.php
Normal file
35
tests/PhpWord/Tests/FootnoteTest.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Tests;
|
||||
|
||||
use PhpOffice\PhpWord\Footnote;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Footnote
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class FootnoteTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test add, get, and count footnote elements and links
|
||||
*/
|
||||
public function testFootnote()
|
||||
{
|
||||
$footnoteElement = new \PhpOffice\PhpWord\Section\Footnote();
|
||||
$rIdFootnote = Footnote::addFootnoteElement($footnoteElement);
|
||||
$rIdLink = Footnote::addFootnoteLinkElement('http://test.com');
|
||||
|
||||
$this->assertEquals(2, $rIdFootnote);
|
||||
$this->assertEquals(1, $rIdLink);
|
||||
$this->assertEquals(1, count(Footnote::getFootnoteElements()));
|
||||
$this->assertEquals(1, count(Footnote::getFootnoteLinkElements()));
|
||||
}
|
||||
}
|
||||
@ -15,15 +15,14 @@ use PhpOffice\PhpWord\IOFactory;
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\IOFactory
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\IOFactory
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
final class IOFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
class IOFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::createWriter
|
||||
* Create existing writer
|
||||
*/
|
||||
final public function testExistingWriterCanBeCreated()
|
||||
public function testExistingWriterCanBeCreated()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
'PhpOffice\\PhpWord\\Writer\\Word2007',
|
||||
@ -32,18 +31,19 @@ final class IOFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createWriter
|
||||
* Create non-existing writer
|
||||
*
|
||||
* @expectedException \PhpOffice\PhpWord\Exceptions\Exception
|
||||
*/
|
||||
final public function testNonexistentWriterCanNotBeCreated()
|
||||
public function testNonexistentWriterCanNotBeCreated()
|
||||
{
|
||||
IOFactory::createWriter(new PhpWord(), 'Word2006');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createReader
|
||||
* Create existing reader
|
||||
*/
|
||||
final public function testExistingReaderCanBeCreated()
|
||||
public function testExistingReaderCanBeCreated()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
'PhpOffice\\PhpWord\\Reader\\Word2007',
|
||||
@ -52,11 +52,24 @@ final class IOFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createReader
|
||||
* Create non-existing reader
|
||||
*
|
||||
* @expectedException \PhpOffice\PhpWord\Exceptions\Exception
|
||||
*/
|
||||
final public function testNonexistentReaderCanNotBeCreated()
|
||||
public function testNonexistentReaderCanNotBeCreated()
|
||||
{
|
||||
IOFactory::createReader('Word2006');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load document
|
||||
*/
|
||||
public function testLoad()
|
||||
{
|
||||
$file = __DIR__ . "/_files/templates/blank.docx";
|
||||
$this->assertInstanceOf(
|
||||
'PhpOffice\\PhpWord\\PhpWord',
|
||||
IOFactory::load($file)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,25 +11,34 @@ namespace PhpOffice\PhpWord\Tests;
|
||||
|
||||
use PhpOffice\PhpWord\Media;
|
||||
use PhpOffice\PhpWord\Section;
|
||||
use PhpOffice\PhpWord\Section\Image;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Media
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Media
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class MediaTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Get section media elements
|
||||
*/
|
||||
public function testGetSectionMediaElementsWithNull()
|
||||
{
|
||||
$this->assertEquals(Media::getSectionMediaElements(), array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Count section media elements
|
||||
*/
|
||||
public function testCountSectionMediaElementsWithNull()
|
||||
{
|
||||
$this->assertEquals(Media::countSectionMediaElements(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get header media elements
|
||||
*/
|
||||
public function testGetHeaderMediaElements()
|
||||
{
|
||||
$this->assertAttributeEquals(
|
||||
@ -39,6 +48,9 @@ class MediaTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get footer media elements
|
||||
*/
|
||||
public function testGetFooterMediaElements()
|
||||
{
|
||||
$this->assertAttributeEquals(
|
||||
@ -49,24 +61,60 @@ class MediaTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Todo: add memory image to this test
|
||||
*
|
||||
* @covers \PhpOffice\PhpWord\Media::addSectionMediaElement
|
||||
* Add section media element
|
||||
*/
|
||||
public function testAddSectionMediaElement()
|
||||
{
|
||||
$section = new Section(0);
|
||||
$section->addImage(__DIR__ . "/_files/images/mars_noext_jpg");
|
||||
$section->addImage(__DIR__ . "/_files/images/mars.jpg");
|
||||
$section->addImage(__DIR__ . "/_files/images/mario.gif");
|
||||
$section->addImage(__DIR__ . "/_files/images/firefox.png");
|
||||
$section->addImage(__DIR__ . "/_files/images/duke_nukem.bmp");
|
||||
$section->addImage(__DIR__ . "/_files/images/angela_merkel.tif");
|
||||
$local = __DIR__ . "/_files/images/mars.jpg";
|
||||
$object = __DIR__ . "/_files/documents/sheet.xls";
|
||||
$remote = 'http://php.net/images/logos/php-med-trans-light.gif';
|
||||
Media::addSectionMediaElement($local, 'image');
|
||||
Media::addSectionMediaElement($local, 'image');
|
||||
Media::addSectionMediaElement($remote, 'image', new Image($remote));
|
||||
Media::addSectionMediaElement($object, 'oleObject');
|
||||
Media::addSectionMediaElement($object, 'oleObject');
|
||||
|
||||
$elements = $section->getElements();
|
||||
$this->assertEquals(6, count($elements));
|
||||
foreach ($elements as $element) {
|
||||
$this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element);
|
||||
$this->assertEquals(3, Media::countSectionMediaElements());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add section link
|
||||
*/
|
||||
public function testAddSectionLinkElement()
|
||||
{
|
||||
$expected = Media::countSectionMediaElements() + 7;
|
||||
$actual = Media::addSectionLinkElement('http://test.com');
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->assertEquals(1, Media::countSectionMediaElements('links'));
|
||||
$this->assertEquals(1, count(Media::getSectionMediaElements('links')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add header media element
|
||||
*/
|
||||
public function testAddHeaderMediaElement()
|
||||
{
|
||||
$local = __DIR__ . "/_files/images/mars.jpg";
|
||||
$remote = 'http://php.net/images/logos/php-med-trans-light.gif';
|
||||
Media::addHeaderMediaElement(1, $local);
|
||||
Media::addHeaderMediaElement(1, $local);
|
||||
Media::addHeaderMediaElement(1, $remote, new Image($remote));
|
||||
|
||||
$this->assertEquals(2, Media::countHeaderMediaElements('header1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add footer media element
|
||||
*/
|
||||
public function testAddFooterMediaElement()
|
||||
{
|
||||
$local = __DIR__ . "/_files/images/mars.jpg";
|
||||
$remote = 'http://php.net/images/logos/php-med-trans-light.gif';
|
||||
Media::addFooterMediaElement(1, $local);
|
||||
Media::addFooterMediaElement(1, $local);
|
||||
Media::addFooterMediaElement(1, $remote, new Image($remote));
|
||||
|
||||
$this->assertEquals(2, Media::countFooterMediaElements('footer1'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,17 +17,12 @@ use PhpOffice\PhpWord\Style;
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\PhpWord
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\PhpWord
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class PhpWordTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test object creation
|
||||
*
|
||||
* @covers ::getDocumentProperties
|
||||
* @covers ::getDefaultFontName
|
||||
* @covers ::getDefaultFontSize
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
@ -39,9 +34,6 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* Test set/get document properties
|
||||
*
|
||||
* @covers ::setDocumentProperties
|
||||
* @covers ::getDocumentProperties
|
||||
*/
|
||||
public function testSetGetDocumentProperties()
|
||||
{
|
||||
@ -55,9 +47,6 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* Test create/get section
|
||||
*
|
||||
* @covers ::createSection
|
||||
* @covers ::getSections
|
||||
*/
|
||||
public function testCreateGetSections()
|
||||
{
|
||||
@ -69,9 +58,6 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* Test set/get default font name
|
||||
*
|
||||
* @covers ::setDefaultFontName
|
||||
* @covers ::getDefaultFontName
|
||||
*/
|
||||
public function testSetGetDefaultFontName()
|
||||
{
|
||||
@ -84,9 +70,6 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* Test set/get default font size
|
||||
*
|
||||
* @covers ::setDefaultFontSize
|
||||
* @covers ::getDefaultFontSize
|
||||
*/
|
||||
public function testSetGetDefaultFontSize()
|
||||
{
|
||||
@ -99,9 +82,6 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* Test set default paragraph style
|
||||
*
|
||||
* @covers ::setDefaultParagraphStyle
|
||||
* @covers ::loadTemplate
|
||||
*/
|
||||
public function testSetDefaultParagraphStyle()
|
||||
{
|
||||
@ -112,11 +92,6 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* Test add styles
|
||||
*
|
||||
* @covers ::addParagraphStyle
|
||||
* @covers ::addFontStyle
|
||||
* @covers ::addTableStyle
|
||||
* @covers ::addLinkStyle
|
||||
*/
|
||||
public function testAddStyles()
|
||||
{
|
||||
@ -138,8 +113,6 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* Test add title style
|
||||
*
|
||||
* @covers ::addTitleStyle
|
||||
*/
|
||||
public function testAddTitleStyle()
|
||||
{
|
||||
@ -152,8 +125,6 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* Test load template
|
||||
*
|
||||
* @covers ::loadTemplate
|
||||
*/
|
||||
public function testLoadTemplate()
|
||||
{
|
||||
@ -169,7 +140,6 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* Test load template exception
|
||||
*
|
||||
* @covers ::loadTemplate
|
||||
* @expectedException \PhpOffice\PhpWord\Exceptions\Exception
|
||||
*/
|
||||
public function testLoadTemplateException()
|
||||
|
||||
@ -10,17 +10,17 @@
|
||||
namespace PhpOffice\PhpWord\Tests;
|
||||
|
||||
use PhpOffice\PhpWord\Section;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Section
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Section
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class SectionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::getSettings
|
||||
* Get settings
|
||||
*/
|
||||
public function testGetSettings()
|
||||
{
|
||||
@ -29,7 +29,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getElements
|
||||
* Get elements
|
||||
*/
|
||||
public function testGetElements()
|
||||
{
|
||||
@ -38,7 +38,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getFooter
|
||||
* Get footer
|
||||
*/
|
||||
public function testGetFooter()
|
||||
{
|
||||
@ -47,7 +47,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getHeaders
|
||||
* Get headers
|
||||
*/
|
||||
public function testGetHeaders()
|
||||
{
|
||||
@ -56,7 +56,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setSettings
|
||||
* Set settings
|
||||
*/
|
||||
public function testSetSettings()
|
||||
{
|
||||
@ -67,22 +67,11 @@ class SectionTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::addText
|
||||
* @covers ::addLink
|
||||
* @covers ::addTextBreak
|
||||
* @covers ::addPageBreak
|
||||
* @covers ::addTable
|
||||
* @covers ::addListItem
|
||||
* @covers ::addObject
|
||||
* @covers ::addImage
|
||||
* @covers ::addTOC
|
||||
* @covers ::addTitle
|
||||
* @covers ::createTextRun
|
||||
* @covers ::createFootnote
|
||||
* Add elements
|
||||
*/
|
||||
public function testAddElements()
|
||||
{
|
||||
$objectSource = __DIR__ . "/_files/documents/sheet.xls";
|
||||
$objectSource = __DIR__ . "/_files/documents/reader.docx";
|
||||
$imageSource = __DIR__ . "/_files/images/PhpWord.png";
|
||||
$imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif';
|
||||
|
||||
@ -95,36 +84,61 @@ class SectionTest extends \PHPUnit_Framework_TestCase
|
||||
$section->addListItem(utf8_decode('ä'));
|
||||
$section->addObject($objectSource);
|
||||
$section->addImage($imageSource);
|
||||
$section->addImage($imageUrl);
|
||||
$section->addTOC();
|
||||
$section->addMemoryImage($imageUrl);
|
||||
$section->addTitle(utf8_decode('ä'), 1);
|
||||
$section->createTextRun();
|
||||
$section->createFootnote();
|
||||
$section->addTOC();
|
||||
|
||||
$elementCollection = $section->getElements();
|
||||
$elementType = 'Link';
|
||||
$this->assertInstanceOf("PhpOffice\\PhpWord\\Section\\{$elementType}", $elementCollection[1]);
|
||||
// $elementTypes = array('Text', 'Link', 'TextBreak', 'PageBreak',
|
||||
// 'Table', 'ListItem', 'Object', 'Image', 'Image', 'TOC',
|
||||
// 'Title', 'TextRun');
|
||||
// $i = 0;
|
||||
// foreach ($elementTypes as $elementType) {
|
||||
// $this->assertInstanceOf("PhpOffice\\PhpWord\\Section\\{$elementType}", $elementCollection[$i]);
|
||||
// $i++;
|
||||
// }
|
||||
$elementTypes = array('Text', 'Link', 'TextBreak', 'PageBreak',
|
||||
'Table', 'ListItem', 'Object', 'Image', 'Image',
|
||||
'Title', 'TextRun', 'Footnote');
|
||||
$i = 0;
|
||||
foreach ($elementTypes as $elementType) {
|
||||
$this->assertInstanceOf("PhpOffice\\PhpWord\\Section\\{$elementType}", $elementCollection[$i]);
|
||||
$i++;
|
||||
}
|
||||
$this->assertInstanceOf("PhpOffice\\PhpWord\\TOC", $elementCollection[$i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::createHeader
|
||||
* @covers ::createFooter
|
||||
* Test add object exception
|
||||
*
|
||||
* @expectedException \PhpOffice\PhpWord\Exceptions\InvalidObjectException
|
||||
*/
|
||||
public function testAddObjectException()
|
||||
{
|
||||
$source = __DIR__ . "/_files/xsl/passthrough.xsl";
|
||||
$section = new Section(0);
|
||||
$section->addObject($source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add title with predefined style
|
||||
*/
|
||||
public function testAddTitleWithStyle()
|
||||
{
|
||||
Style::addTitleStyle(1, array('size' => 14));
|
||||
$section = new Section(0);
|
||||
$section->addTitle('Test', 1);
|
||||
$elementCollection = $section->getElements();
|
||||
|
||||
$this->assertInstanceOf("PhpOffice\\PhpWord\\Section\\Title", $elementCollection[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create header footer
|
||||
*/
|
||||
public function testCreateHeaderFooter()
|
||||
{
|
||||
$object = new Section(0);
|
||||
$elements = array('Header', 'Footer');
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$method = "create{$element}";
|
||||
$this->assertInstanceOf("PhpOffice\\PhpWord\\Section\\{$element}", $object->$method());
|
||||
}
|
||||
$this->assertFalse($object->hasDifferentFirstPage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,14 +14,12 @@ use PhpOffice\PhpWord\Settings;
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Settings
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Settings
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class SettingsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::setCompatibility
|
||||
* @covers ::getCompatibility
|
||||
* Get and set compatibity option
|
||||
*/
|
||||
public function testGetSetCompatibility()
|
||||
{
|
||||
|
||||
@ -55,6 +55,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
|
||||
'strikethrough' => false,
|
||||
'color' => PhpWord::DEFAULT_FONT_COLOR,
|
||||
'fgColor' => null,
|
||||
'hint' => PhpWord::DEFAULT_FONT_CONTENT_TYPE,
|
||||
);
|
||||
foreach ($attributes as $key => $default) {
|
||||
$get = "get{$key}";
|
||||
@ -78,19 +79,23 @@ class FontTest extends \PHPUnit_Framework_TestCase
|
||||
'bold' => true,
|
||||
'italic' => true,
|
||||
'superScript' => true,
|
||||
'subScript' => true,
|
||||
'subScript' => false,
|
||||
'underline' => Font::UNDERLINE_HEAVY,
|
||||
'strikethrough' => true,
|
||||
'color' => '999999',
|
||||
'fgColor' => '999999',
|
||||
'hint' => 'eastAsia',
|
||||
);
|
||||
$object->setArrayStyle($attributes);
|
||||
foreach ($attributes as $key => $value) {
|
||||
$get = "get{$key}";
|
||||
$object->setStyleValue("_$key", $value);
|
||||
$this->assertEquals($value, $object->$get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set line height
|
||||
*/
|
||||
public function testLineHeight()
|
||||
{
|
||||
$phpWord = new PhpWord();
|
||||
@ -121,4 +126,25 @@ class FontTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(720, $lineHeight);
|
||||
$this->assertEquals('auto', $lineRule);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test line height floatval
|
||||
*/
|
||||
public function testLineHeightFloatval()
|
||||
{
|
||||
$object = new Font(null, array('align' => 'center'));
|
||||
$object->setLineHeight('1.5pt');
|
||||
$this->assertEquals(1.5, $object->getLineHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test line height exception by using nonnumeric value
|
||||
*
|
||||
* @expectedException \PhpOffice\PhpWord\Exceptions\InvalidStyleException
|
||||
*/
|
||||
public function testLineHeightException()
|
||||
{
|
||||
$object = new Font();
|
||||
$object->setLineHeight('a');
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,4 +137,15 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
|
||||
$object->setLineHeight('12.5pt');
|
||||
$this->assertEquals(12.5, $object->getLineHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test line height exception by using nonnumeric value
|
||||
*
|
||||
* @expectedException \PhpOffice\PhpWord\Exceptions\InvalidStyleException
|
||||
*/
|
||||
public function testLineHeightException()
|
||||
{
|
||||
$object = new Paragraph();
|
||||
$object->setLineHeight('a');
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,9 +20,9 @@ use PhpOffice\PhpWord\Style\Row;
|
||||
class RowTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test properties with normal value
|
||||
* Test properties with boolean value
|
||||
*/
|
||||
public function testProperties()
|
||||
public function testBooleanValue()
|
||||
{
|
||||
$object = new Row();
|
||||
|
||||
@ -45,4 +45,23 @@ class RowTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($expected, $object->$get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test properties with nonboolean values, which will return default value
|
||||
*/
|
||||
public function testNonBooleanValue()
|
||||
{
|
||||
$object = new Row();
|
||||
|
||||
$properties = array(
|
||||
'tblHeader' => 'a',
|
||||
'cantSplit' => 'b',
|
||||
);
|
||||
foreach ($properties as $key => $value) {
|
||||
$set = "set{$key}";
|
||||
$get = "get{$key}";
|
||||
$object->$set($value);
|
||||
$this->assertFalse($object->$get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,7 +14,6 @@ use PhpOffice\PhpWord\Style\Table;
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Style\Table
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Style\Table
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class TableTest extends \PHPUnit_Framework_TestCase
|
||||
@ -25,7 +24,6 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
||||
* There are 3 variables for class constructor:
|
||||
* - $styleTable: Define table styles
|
||||
* - $styleFirstRow: Define style for the first row
|
||||
* - $styleLastRow: Define style for the last row (reserved)
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
@ -138,4 +136,28 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
$this->assertEquals($values, $object->getCellMargin());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set style value for various special value types
|
||||
*/
|
||||
public function testSetStyleValue()
|
||||
{
|
||||
$object = new Table();
|
||||
$object->setStyleValue('_borderSize', 120);
|
||||
$object->setStyleValue('_cellMargin', 240);
|
||||
$object->setStyleValue('_borderColor', '999999');
|
||||
|
||||
$this->assertEquals(
|
||||
array(120, 120, 120, 120, 120, 120),
|
||||
$object->getBorderSize()
|
||||
);
|
||||
$this->assertEquals(
|
||||
array(240, 240, 240, 240),
|
||||
$object->getCellMargin()
|
||||
);
|
||||
$this->assertEquals(
|
||||
array('999999', '999999', '999999', '999999', '999999', '999999'),
|
||||
$object->getBorderColor()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,16 +14,12 @@ use PhpOffice\PhpWord\Style;
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Style
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Style
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class StyleTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::addParagraphStyle
|
||||
* @covers ::addFontStyle
|
||||
* @covers ::addLinkStyle
|
||||
* @covers ::addTitleStyle
|
||||
* Add and get paragraph, font, link, title, and table styles
|
||||
*/
|
||||
public function testStyles()
|
||||
{
|
||||
@ -34,6 +30,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
|
||||
'Link' => 'Font', 'Table' => 'Table',
|
||||
'Heading_1' => 'Font', 'Normal' => 'Paragraph');
|
||||
$elementCount = 6;
|
||||
|
||||
Style::addParagraphStyle('Paragraph', $paragraph);
|
||||
Style::addFontStyle('Font', $font);
|
||||
Style::addLinkStyle('Link', $font);
|
||||
@ -47,4 +44,16 @@ class StyleTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
$this->assertNull(Style::getStyle('Unknown'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default paragraph style
|
||||
*/
|
||||
public function testDefaultParagraphStyle()
|
||||
{
|
||||
$paragraph = array('align' => 'center');
|
||||
|
||||
Style::setDefaultParagraphStyle($paragraph);
|
||||
|
||||
$this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\Paragraph", Style::getStyle('Normal'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,17 +14,14 @@ use PhpOffice\PhpWord\TOC;
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\TOC
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\TOC
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class TOCTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getStyleTOC
|
||||
* @covers ::getStyleFont
|
||||
* Construct with font and TOC style in array format
|
||||
*/
|
||||
public function testConstruct()
|
||||
public function testConstructWithStyleArray()
|
||||
{
|
||||
$expected = array(
|
||||
'tabPos' => 9062,
|
||||
@ -44,12 +41,21 @@ class TOCTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::addTitle
|
||||
* @covers ::getTitles
|
||||
* Construct with named font style
|
||||
*/
|
||||
public function testConstructWithStyleName()
|
||||
{
|
||||
$object = new TOC('Font Style');
|
||||
$tocStyle = $object->getStyleTOC();
|
||||
|
||||
$this->assertEquals('Font Style', $object->getStyleFont());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add and get title
|
||||
*/
|
||||
public function testAddAndGetTitle()
|
||||
{
|
||||
// Prepare variables
|
||||
$titleCount = 3;
|
||||
$anchor = '_Toc' . (252634154 + $titleCount);
|
||||
$bookmark = $titleCount - 1;
|
||||
@ -59,14 +65,12 @@ class TOCTest extends \PHPUnit_Framework_TestCase
|
||||
'Heading 3' => 3,
|
||||
);
|
||||
|
||||
// @covers ::addTitle
|
||||
foreach ($titles as $text => $depth) {
|
||||
$response = TOC::addTitle($text, $depth);
|
||||
}
|
||||
$this->assertEquals($anchor, $response[0]);
|
||||
$this->assertEquals($bookmark, $response[1]);
|
||||
|
||||
// @covers ::getTitles
|
||||
$i = 0;
|
||||
$savedTitles = TOC::getTitles();
|
||||
foreach ($titles as $text => $depth) {
|
||||
|
||||
@ -15,12 +15,15 @@ use PhpOffice\PhpWord\Template;
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Template
|
||||
*
|
||||
* @covers \PhpOffice\PhpWord\Template
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Template
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
final class TemplateTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Template can be saved in temporary location
|
||||
*
|
||||
* @covers ::save
|
||||
* @test
|
||||
*/
|
||||
@ -60,6 +63,8 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* XSL stylesheet can be applied
|
||||
*
|
||||
* @covers ::applyXslStyleSheet
|
||||
* @depends testTemplateCanBeSavedInTemporaryLocation
|
||||
* @test
|
||||
@ -86,6 +91,8 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* XSL stylesheet cannot be applied on failure in setting parameter value
|
||||
*
|
||||
* @covers ::applyXslStyleSheet
|
||||
* @expectedException \PhpOffice\PhpWord\Exceptions\Exception
|
||||
* @expectedExceptionMessage Could not set values for the given XSL style sheet parameters.
|
||||
@ -106,6 +113,8 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* XSL stylesheet can be applied on failure of loading XML from template
|
||||
*
|
||||
* @covers ::applyXslStyleSheet
|
||||
* @expectedException \PhpOffice\PhpWord\Exceptions\Exception
|
||||
* @expectedExceptionMessage Could not load XML from the given template.
|
||||
@ -126,10 +135,7 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getVariables
|
||||
* @covers ::setValue
|
||||
* @covers ::cloneRow
|
||||
* @covers ::saveAs
|
||||
* Get variables and clone row
|
||||
*/
|
||||
public function testCloneRow()
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user