Docblock updates

This commit is contained in:
Ivan Lanin 2014-03-30 14:15:23 +07:00
parent 05a4b95255
commit 0e2f476cc2
29 changed files with 271 additions and 31 deletions

View File

@ -3,7 +3,7 @@
* Footer file * Footer file
*/ */
// Do not show execution time for index // Do not show execution time for index
if (!$isIndexFile) { if (!IS_INDEX) {
echo date('H:i:s'), " Done writing file(s)", EOL; echo date('H:i:s'), " Done writing file(s)", EOL;
echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
} }
@ -11,12 +11,12 @@ if (!$isIndexFile) {
if (CLI) { if (CLI) {
echo 'The results are stored in the "results" subdirectory.', EOL; echo 'The results are stored in the "results" subdirectory.', EOL;
} else { } else {
if (!$isIndexFile) { if (!IS_INDEX) {
$types = array('docx', 'odt', 'rtf'); $types = array('docx', 'odt', 'rtf');
echo '<p>&nbsp;</p>'; echo '<p>&nbsp;</p>';
echo '<p>Results: '; echo '<p>Results: ';
foreach ($types as $type) { foreach ($types as $type) {
$result = "results/{$sampleFile}.{$type}"; $result = 'results/' . SCRIPT_FILENAME . '.' . $type;
if (file_exists($result)) { if (file_exists($result)) {
echo "<a href='{$result}' class='btn btn-primary'>{$type}</a> "; echo "<a href='{$result}' class='btn btn-primary'>{$type}</a> ";
} }

View File

@ -5,6 +5,8 @@
error_reporting(E_ALL); error_reporting(E_ALL);
define('CLI', (PHP_SAPI == 'cli') ? true : false); define('CLI', (PHP_SAPI == 'cli') ? true : false);
define('EOL', CLI ? PHP_EOL : '<br />'); define('EOL', CLI ? PHP_EOL : '<br />');
define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php'));
define('IS_INDEX', SCRIPT_FILENAME == 'index');
require_once '../src/PhpWord/Autoloader.php'; require_once '../src/PhpWord/Autoloader.php';
PhpOffice\PhpWord\Autoloader::register(); PhpOffice\PhpWord\Autoloader::register();
@ -15,12 +17,10 @@ if (CLI) {
} }
// Set titles and names // Set titles and names
$sampleFile = basename($_SERVER['SCRIPT_FILENAME'], '.php'); $pageHeading = str_replace('_', ' ', SCRIPT_FILENAME);
$isIndexFile = ($sampleFile == 'index'); $pageTitle = IS_INDEX ? 'Welcome to ' : "{$pageHeading} - ";
$pageHeading = str_replace('_', ' ', $sampleFile);
$pageTitle = $isIndexFile ? 'Welcome to ' : "{$pageHeading} - ";
$pageTitle .= 'PHPWord'; $pageTitle .= 'PHPWord';
$pageHeading = $isIndexFile ? '' : "<h1>{$pageHeading}</h1>"; $pageHeading = IS_INDEX ? '' : "<h1>{$pageHeading}</h1>";
// Populate samples // Populate samples
$files = ''; $files = '';
if ($handle = opendir('.')) { if ($handle = opendir('.')) {

View File

@ -421,8 +421,9 @@ class Section
* *
* @param string $name * @param string $name
* @param string $text * @param string $text
* @param mixed $style * @param mixed $styleFont
* @return PHPWord_Section_CheckBox * @param mixed $styleParagraph
* @return \PhpOffice\PhpWord\Section\CheckBox
*/ */
public function addCheckBox($name, $text, $styleFont = null, $styleParagraph = null) public function addCheckBox($name, $text, $styleFont = null, $styleParagraph = null)
{ {

View File

@ -129,6 +129,8 @@ class CheckBox
} }
/** /**
* Set name content
*
* @param string $name * @param string $name
* @return $this * @return $this
*/ */
@ -149,6 +151,8 @@ class CheckBox
} }
/** /**
* Set text content
*
* @param string $text * @param string $text
* @return $this * @return $this
*/ */
@ -159,7 +163,7 @@ class CheckBox
} }
/** /**
* Get Text content * Get text content
* *
* @return string * @return string
*/ */

View File

@ -296,8 +296,9 @@ class Cell
* *
* @param string $name * @param string $name
* @param string $text * @param string $text
* @param mixed $style * @param mixed $styleFont
* @return PHPWord_Section_CheckBox * @param mixed $styleParagraph
* @return \PhpOffice\PhpWord\Section\CheckBox
*/ */
public function addCheckBox($name, $text, $styleFont = null, $styleParagraph = null) public function addCheckBox($name, $text, $styleFont = null, $styleParagraph = null)
{ {

View File

@ -1220,6 +1220,9 @@ class Base extends WriterPart
/** /**
* Write CheckBox * Write CheckBox
*
* @param boolean $withoutP
* @param boolean $checkState
*/ */
protected function _writeCheckBox(XMLWriter $xmlWriter, CheckBox $checkbox, $withoutP = false, $checkState = false) protected function _writeCheckBox(XMLWriter $xmlWriter, CheckBox $checkbox, $withoutP = false, $checkState = false)
{ {

View File

@ -20,6 +20,8 @@ use PhpOffice\PhpWord\Exceptions\Exception;
class ExceptionTest extends \PHPUnit_Framework_TestCase class ExceptionTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* Throw new exception
*
* @expectedException \PhpOffice\PhpWord\Exceptions\Exception * @expectedException \PhpOffice\PhpWord\Exceptions\Exception
* @covers \PhpOffice\PhpWord\Exceptions\Exception * @covers \PhpOffice\PhpWord\Exceptions\Exception
*/ */

View File

@ -20,6 +20,8 @@ use PhpOffice\PhpWord\Exceptions\InvalidImageException;
class InvalidImageExceptionTest extends \PHPUnit_Framework_TestCase class InvalidImageExceptionTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* Throw new exception
*
* @expectedException \PhpOffice\PhpWord\Exceptions\InvalidImageException * @expectedException \PhpOffice\PhpWord\Exceptions\InvalidImageException
* @covers \PhpOffice\PhpWord\Exceptions\InvalidImageException * @covers \PhpOffice\PhpWord\Exceptions\InvalidImageException
*/ */

View File

@ -20,6 +20,8 @@ use PhpOffice\PhpWord\Exceptions\InvalidStyleException;
class InvalidStyleExceptionTest extends \PHPUnit_Framework_TestCase class InvalidStyleExceptionTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* Throw new exception
*
* @expectedException \PhpOffice\PhpWord\Exceptions\InvalidStyleException * @expectedException \PhpOffice\PhpWord\Exceptions\InvalidStyleException
* @covers \PhpOffice\PhpWord\Exceptions\InvalidStyleException * @covers \PhpOffice\PhpWord\Exceptions\InvalidStyleException
*/ */

View File

@ -20,6 +20,8 @@ use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException;
class UnsupportedImageTypeExceptionTest extends \PHPUnit_Framework_TestCase class UnsupportedImageTypeExceptionTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* Throw new exception
*
* @expectedException \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException * @expectedException \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException
* @covers \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException * @covers \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException
*/ */

View File

@ -41,6 +41,8 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
} }
/** /**
* Can read exception
*
* @expectedException \PhpOffice\PhpWord\Exceptions\Exception * @expectedException \PhpOffice\PhpWord\Exceptions\Exception
*/ */
public function testCanReadFailed() public function testCanReadFailed()
@ -54,6 +56,9 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
$object = IOFactory::load($fqFilename); $object = IOFactory::load($fqFilename);
} }
/**
* Load
*/
public function testLoad() public function testLoad()
{ {
$fqFilename = join( $fqFilename = join(

View File

@ -14,11 +14,13 @@ use PhpOffice\PhpWord\Section\Footer\PreserveText;
/** /**
* Test class for PhpOffice\PhpWord\Section\Footer\PreserveText * Test class for PhpOffice\PhpWord\Section\Footer\PreserveText
* *
* @coversDefaultClass \PhpOffice\PhpWord\Section\Footer\PreserveText
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class PreserveTextTest extends \PHPUnit_Framework_TestCase class PreserveTextTest extends \PHPUnit_Framework_TestCase
{ {
/**
* Create new instance
*/
public function testConstruct() public function testConstruct()
{ {
$oPreserveText = new PreserveText(); $oPreserveText = new PreserveText();
@ -29,6 +31,9 @@ class PreserveTextTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oPreserveText->getParagraphStyle(), null); $this->assertEquals($oPreserveText->getParagraphStyle(), null);
} }
/**
* Create new instance with style name
*/
public function testConstructWithString() public function testConstructWithString()
{ {
$oPreserveText = new PreserveText('text', 'styleFont', 'styleParagraph'); $oPreserveText = new PreserveText('text', 'styleFont', 'styleParagraph');
@ -37,6 +42,9 @@ class PreserveTextTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oPreserveText->getParagraphStyle(), 'styleParagraph'); $this->assertEquals($oPreserveText->getParagraphStyle(), 'styleParagraph');
} }
/**
* Create new instance with array
*/
public function testConstructWithArray() public function testConstructWithArray()
{ {
$oPreserveText = new PreserveText( $oPreserveText = new PreserveText(

View File

@ -20,6 +20,9 @@ use PhpOffice\PhpWord\Style\Font;
*/ */
class LinkTest extends \PHPUnit_Framework_TestCase class LinkTest extends \PHPUnit_Framework_TestCase
{ {
/**
* Create new instance
*/
public function testConstructDefault() public function testConstructDefault()
{ {
$oLink = new Link('http://www.google.com'); $oLink = new Link('http://www.google.com');
@ -31,6 +34,9 @@ class LinkTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oLink->getParagraphStyle(), null); $this->assertEquals($oLink->getParagraphStyle(), null);
} }
/**
* Create new instance with array
*/
public function testConstructWithParamsArray() public function testConstructWithParamsArray()
{ {
$oLink = new Link( $oLink = new Link(
@ -47,6 +53,9 @@ class LinkTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oLink->getParagraphStyle()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oLink->getParagraphStyle());
} }
/**
* Create new instance with style name string
*/
public function testConstructWithParamsString() public function testConstructWithParamsString()
{ {
$oLink = new Link('http://www.google.com', null, 'fontStyle', 'paragraphStyle'); $oLink = new Link('http://www.google.com', null, 'fontStyle', 'paragraphStyle');
@ -55,6 +64,9 @@ class LinkTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oLink->getParagraphStyle(), 'paragraphStyle'); $this->assertEquals($oLink->getParagraphStyle(), 'paragraphStyle');
} }
/**
* Set/get relation Id
*/
public function testRelationId() public function testRelationId()
{ {
$oLink = new Link('http://www.google.com'); $oLink = new Link('http://www.google.com');

View File

@ -19,6 +19,9 @@ use PhpOffice\PhpWord\Section\ListItem;
*/ */
class ListItemTest extends \PHPUnit_Framework_TestCase class ListItemTest extends \PHPUnit_Framework_TestCase
{ {
/**
* Get text object
*/
public function testText() public function testText()
{ {
$oListItem = new ListItem('text'); $oListItem = new ListItem('text');
@ -26,6 +29,9 @@ class ListItemTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $oListItem->getTextObject()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $oListItem->getTextObject());
} }
/**
* Get style
*/
public function testStyle() public function testStyle()
{ {
$oListItem = new ListItem( $oListItem = new ListItem(
@ -42,6 +48,9 @@ class ListItemTest extends \PHPUnit_Framework_TestCase
); );
} }
/**
* Get depth
*/
public function testDepth() public function testDepth()
{ {
$iVal = rand(1, 1000); $iVal = rand(1, 1000);

View File

@ -19,6 +19,9 @@ use PhpOffice\PhpWord\Section\Object;
*/ */
class ObjectTest extends \PHPUnit_Framework_TestCase class ObjectTest extends \PHPUnit_Framework_TestCase
{ {
/**
* Create new instance with supported files
*/
public function testConstructWithSupportedFiles() public function testConstructWithSupportedFiles()
{ {
$src = __DIR__ . "/../_files/documents/sheet.xls"; $src = __DIR__ . "/../_files/documents/sheet.xls";
@ -29,6 +32,9 @@ class ObjectTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oObject->getSource(), $src); $this->assertEquals($oObject->getSource(), $src);
} }
/**
* Create new instance with non-supported files
*/
public function testConstructWithNotSupportedFiles() public function testConstructWithNotSupportedFiles()
{ {
$src = __DIR__ . "/../_files/xsl/passthrough.xsl"; $src = __DIR__ . "/../_files/xsl/passthrough.xsl";
@ -39,6 +45,9 @@ class ObjectTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oObject->getStyle(), null); $this->assertEquals($oObject->getStyle(), null);
} }
/**
* Create with style
*/
public function testConstructWithSupportedFilesAndStyle() public function testConstructWithSupportedFilesAndStyle()
{ {
$src = __DIR__ . "/../_files/documents/sheet.xls"; $src = __DIR__ . "/../_files/documents/sheet.xls";
@ -49,6 +58,9 @@ class ObjectTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oObject->getSource(), $src); $this->assertEquals($oObject->getSource(), $src);
} }
/**
* Set/get relation Id
*/
public function testRelationId() public function testRelationId()
{ {
$src = __DIR__ . "/../_files/documents/sheet.xls"; $src = __DIR__ . "/../_files/documents/sheet.xls";
@ -59,6 +71,9 @@ class ObjectTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oObject->getRelationId(), $iVal); $this->assertEquals($oObject->getRelationId(), $iVal);
} }
/**
* Set/get image relation Id
*/
public function testImageRelationId() public function testImageRelationId()
{ {
$src = __DIR__ . "/../_files/documents/sheet.xls"; $src = __DIR__ . "/../_files/documents/sheet.xls";
@ -69,6 +84,9 @@ class ObjectTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oObject->getImageRelationId(), $iVal); $this->assertEquals($oObject->getImageRelationId(), $iVal);
} }
/**
* Set/get object relation Id
*/
public function testObjectId() public function testObjectId()
{ {
$src = __DIR__ . "/../_files/documents/sheet.xls"; $src = __DIR__ . "/../_files/documents/sheet.xls";

View File

@ -57,6 +57,9 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($iVal, $oSettings->getHeaderHeight()); $this->assertEquals($iVal, $oSettings->getHeaderHeight());
} }
/**
* Set/get margin
*/
public function testMargin() public function testMargin()
{ {
// Section Settings // Section Settings
@ -79,6 +82,9 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($iVal, $oSettings->getMarginRight()); $this->assertEquals($iVal, $oSettings->getMarginRight());
} }
/**
* Set/get landscape orientation
*/
public function testOrientationLandscape() public function testOrientationLandscape()
{ {
// Section Settings // Section Settings
@ -90,6 +96,9 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(11906, $oSettings->getPageSizeH()); $this->assertEquals(11906, $oSettings->getPageSizeH());
} }
/**
* Set/get portrait orientation
*/
public function testOrientationPortrait() public function testOrientationPortrait()
{ {
// Section Settings // Section Settings
@ -101,6 +110,9 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(16838, $oSettings->getPageSizeH()); $this->assertEquals(16838, $oSettings->getPageSizeH());
} }
/**
* Set/get border size
*/
public function testBorderSize() public function testBorderSize()
{ {
// Section Settings // Section Settings
@ -131,6 +143,9 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($iVal, $oSettings->getBorderTopSize()); $this->assertEquals($iVal, $oSettings->getBorderTopSize());
} }
/**
* Set/get border color
*/
public function testBorderColor() public function testBorderColor()
{ {
// Section Settings // Section Settings
@ -156,6 +171,9 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('22FF33', $oSettings->getBorderTopColor()); $this->assertEquals('22FF33', $oSettings->getBorderTopColor());
} }
/**
* Set/get page numbering start
*/
public function testNumberingStart() public function testNumberingStart()
{ {
// Section Settings // Section Settings
@ -171,9 +189,11 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertNull($oSettings->getPageNumberingStart()); $this->assertNull($oSettings->getPageNumberingStart());
} }
/**
* Set/get header height
*/
public function testHeader() public function testHeader()
{ {
// Section Settings
$oSettings = new Settings(); $oSettings = new Settings();
$this->assertEquals(720, $oSettings->getHeaderHeight()); $this->assertEquals(720, $oSettings->getHeaderHeight());
@ -186,6 +206,9 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(720, $oSettings->getHeaderHeight()); $this->assertEquals(720, $oSettings->getHeaderHeight());
} }
/**
* Set/get footer height
*/
public function testFooter() public function testFooter()
{ {
// Section Settings // Section Settings
@ -201,6 +224,9 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(720, $oSettings->getFooterHeight()); $this->assertEquals(720, $oSettings->getFooterHeight());
} }
/**
* Set/get column number
*/
public function testColumnsNum() public function testColumnsNum()
{ {
// Section Settings // Section Settings
@ -217,6 +243,9 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(1, $oSettings->getColsNum()); $this->assertEquals(1, $oSettings->getColsNum());
} }
/**
* Set/get column spacing
*/
public function testColumnsSpace() public function testColumnsSpace()
{ {
// Section Settings // Section Settings
@ -233,6 +262,9 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(720, $oSettings->getColsSpace()); $this->assertEquals(720, $oSettings->getColsSpace());
} }
/**
* Set/get break type
*/
public function testBreakType() public function testBreakType()
{ {
// Section Settings // Section Settings

View File

@ -19,6 +19,9 @@ use PhpOffice\PhpWord\Section\Table\Row;
*/ */
class RowTest extends \PHPUnit_Framework_TestCase class RowTest extends \PHPUnit_Framework_TestCase
{ {
/**
* Create new instance
*/
public function testConstruct() public function testConstruct()
{ {
$iVal = rand(1, 1000); $iVal = rand(1, 1000);
@ -31,6 +34,9 @@ class RowTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Row', $oRow->getStyle()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Row', $oRow->getStyle());
} }
/**
* Create new instance with parameters
*/
public function testConstructWithParams() public function testConstructWithParams()
{ {
$iVal = rand(1, 1000); $iVal = rand(1, 1000);
@ -46,6 +52,9 @@ class RowTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Row', $oRow->getStyle()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Row', $oRow->getStyle());
} }
/**
* Add cell
*/
public function testAddCell() public function testAddCell()
{ {
$oRow = new Row('section', 1); $oRow = new Row('section', 1);

View File

@ -19,6 +19,9 @@ use PhpOffice\PhpWord\Section\Table;
*/ */
class TableTest extends \PHPUnit_Framework_TestCase class TableTest extends \PHPUnit_Framework_TestCase
{ {
/**
* Create new instance
*/
public function testConstruct() public function testConstruct()
{ {
$oTable = new Table('section', 1); $oTable = new Table('section', 1);
@ -30,6 +33,9 @@ class TableTest extends \PHPUnit_Framework_TestCase
$this->assertCount(0, $oTable->getRows()); $this->assertCount(0, $oTable->getRows());
} }
/**
* Get style name
*/
public function testStyleText() public function testStyleText()
{ {
$oTable = new Table('section', 1, 'tableStyle'); $oTable = new Table('section', 1, 'tableStyle');
@ -37,6 +43,9 @@ class TableTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oTable->getStyle(), 'tableStyle'); $this->assertEquals($oTable->getStyle(), 'tableStyle');
} }
/**
* Get style array
*/
public function testStyleArray() public function testStyleArray()
{ {
$oTable = new Table( $oTable = new Table(
@ -48,6 +57,9 @@ class TableTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Table', $oTable->getStyle()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Table', $oTable->getStyle());
} }
/**
* Set/get width
*/
public function testWidth() public function testWidth()
{ {
$oTable = new Table('section', 1); $oTable = new Table('section', 1);
@ -56,6 +68,9 @@ class TableTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oTable->getWidth(), $iVal); $this->assertEquals($oTable->getWidth(), $iVal);
} }
/**
* Add/get row
*/
public function testRow() public function testRow()
{ {
$oTable = new Table('section', 1); $oTable = new Table('section', 1);
@ -64,6 +79,9 @@ class TableTest extends \PHPUnit_Framework_TestCase
$this->assertCount(1, $oTable->getRows()); $this->assertCount(1, $oTable->getRows());
} }
/**
* Add cell
*/
public function testCell() public function testCell()
{ {
$oTable = new Table('section', 1); $oTable = new Table('section', 1);

View File

@ -19,6 +19,9 @@ use PhpOffice\PhpWord\Section\Title;
*/ */
class TitleTest extends \PHPUnit_Framework_TestCase class TitleTest extends \PHPUnit_Framework_TestCase
{ {
/**
* Create new instance
*/
public function testConstruct() public function testConstruct()
{ {
$oTitle = new Title('text'); $oTitle = new Title('text');
@ -27,6 +30,9 @@ class TitleTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oTitle->getText(), 'text'); $this->assertEquals($oTitle->getText(), 'text');
} }
/**
* Get style null
*/
public function testStyleNull() public function testStyleNull()
{ {
$oTitle = new Title('text'); $oTitle = new Title('text');
@ -34,6 +40,9 @@ class TitleTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oTitle->getStyle(), null); $this->assertEquals($oTitle->getStyle(), null);
} }
/**
* Get style not null
*/
public function testStyleNotNull() public function testStyleNotNull()
{ {
$oTitle = new Title('text', 1, 'style'); $oTitle = new Title('text', 1, 'style');
@ -41,6 +50,9 @@ class TitleTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oTitle->getStyle(), 'style'); $this->assertEquals($oTitle->getStyle(), 'style');
} }
/**
* Get anchor
*/
public function testAnchor() public function testAnchor()
{ {
$oTitle = new Title('text'); $oTitle = new Title('text');
@ -50,6 +62,9 @@ class TitleTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oTitle->getAnchor(), $iVal); $this->assertEquals($oTitle->getAnchor(), $iVal);
} }
/**
* Get bookmark Id
*/
public function testBookmarkID() public function testBookmarkID()
{ {
$oTitle = new Title('text'); $oTitle = new Title('text');

View File

@ -19,6 +19,9 @@ use PhpOffice\PhpWord\Shared\String;
*/ */
class StringTest extends \PHPUnit_Framework_TestCase class StringTest extends \PHPUnit_Framework_TestCase
{ {
/**
* Is UTF8
*/
public function testIsUTF8() public function testIsUTF8()
{ {
$this->assertTrue(String::isUTF8('')); $this->assertTrue(String::isUTF8(''));
@ -26,12 +29,18 @@ class StringTest extends \PHPUnit_Framework_TestCase
$this->assertFalse(String::isUTF8(utf8_decode('éééé'))); $this->assertFalse(String::isUTF8(utf8_decode('éééé')));
} }
/**
* OOXML to PHP control character
*/
public function testControlCharacterOOXML2PHP() public function testControlCharacterOOXML2PHP()
{ {
$this->assertEquals('', String::controlCharacterOOXML2PHP('')); $this->assertEquals('', String::controlCharacterOOXML2PHP(''));
$this->assertEquals(chr(0x08), String::controlCharacterOOXML2PHP('_x0008_')); $this->assertEquals(chr(0x08), String::controlCharacterOOXML2PHP('_x0008_'));
} }
/**
* PHP to OOXML control character
*/
public function testControlCharacterPHP2OOXML() public function testControlCharacterPHP2OOXML()
{ {
$this->assertEquals('', String::controlCharacterPHP2OOXML('')); $this->assertEquals('', String::controlCharacterPHP2OOXML(''));

View File

@ -16,11 +16,13 @@ use PhpOffice\PhpWord\Tests\TestHelperDOCX;
/** /**
* Test class for PhpOffice\PhpWord\Style\Font * Test class for PhpOffice\PhpWord\Style\Font
* *
* @coversDefaultClass \PhpOffice\PhpWord\Style\Font
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class FontTest extends \PHPUnit_Framework_TestCase class FontTest extends \PHPUnit_Framework_TestCase
{ {
/**
* Tear down after each test
*/
public function tearDown() public function tearDown()
{ {
TestHelperDOCX::clear(); TestHelperDOCX::clear();

View File

@ -17,11 +17,13 @@ use PhpOffice\PhpWord\Tests\TestHelperDOCX;
/** /**
* Test class for PhpOffice\PhpWord\Style\Paragraph * Test class for PhpOffice\PhpWord\Style\Paragraph
* *
* @coversDefaultClass \PhpOffice\PhpWord\Style\Paragraph
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class ParagraphTest extends \PHPUnit_Framework_TestCase class ParagraphTest extends \PHPUnit_Framework_TestCase
{ {
/**
* Tear down after each test
*/
public function tearDown() public function tearDown()
{ {
TestHelperDOCX::clear(); TestHelperDOCX::clear();
@ -97,6 +99,9 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Tabs', $object->getTabs()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Tabs', $object->getTabs());
} }
/**
* Line height
*/
public function testLineHeight() public function testLineHeight()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();

View File

@ -65,6 +65,7 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase
/** /**
* XSL stylesheet can be applied * XSL stylesheet can be applied
* *
* @param string $actualDocumentFqfn
* @covers ::applyXslStyleSheet * @covers ::applyXslStyleSheet
* @depends testTemplateCanBeSavedInTemporaryLocation * @depends testTemplateCanBeSavedInTemporaryLocation
* @test * @test

View File

@ -21,6 +21,8 @@ use PhpOffice\PhpWord\Tests\TestHelperDOCX;
class FooterTest extends \PHPUnit_Framework_TestCase class FooterTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* Write footer
*
* @covers ::writeFooter * @covers ::writeFooter
*/ */
public function testWriteFooter() public function testWriteFooter()

View File

@ -27,6 +27,9 @@ class FootnotesTest extends \PHPUnit_Framework_TestCase
TestHelperDOCX::clear(); TestHelperDOCX::clear();
} }
/**
* Write footnotes
*/
public function testWriteFootnotes() public function testWriteFootnotes()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();

View File

@ -15,13 +15,12 @@ use PhpOffice\PhpWord\Tests\TestHelperDOCX;
/** /**
* Test class for PhpOffice\PhpWord\Writer\Word2007\Header * Test class for PhpOffice\PhpWord\Writer\Word2007\Header
* *
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Header
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class HeaderTest extends \PHPUnit_Framework_TestCase class HeaderTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @covers ::writeHeader * Write header
*/ */
public function testWriteHeader() public function testWriteHeader()
{ {

View File

@ -1,15 +1,32 @@
<?php <?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; namespace PhpOffice\PhpWord\Tests;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\IOFactory; use PhpOffice\PhpWord\IOFactory;
/**
* Test helper class
*/
class TestHelperDOCX class TestHelperDOCX
{ {
/** @var string $file */ /**
* Temporary file name
*
* @var string
*/
static protected $file; static protected $file;
/** /**
* Get document content
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
* @param string $writerName * @param string $writerName
* @return \PhpOffice\PhpWord\Tests\XmlDocument * @return \PhpOffice\PhpWord\Tests\XmlDocument
@ -34,6 +51,9 @@ class TestHelperDOCX
return new XmlDocument(sys_get_temp_dir() . '/PhpWord_Unit_Test/'); return new XmlDocument(sys_get_temp_dir() . '/PhpWord_Unit_Test/');
} }
/**
* Clear document
*/
public static function clear() public static function clear()
{ {
if (\file_exists(self::$file)) { if (\file_exists(self::$file)) {
@ -45,6 +65,8 @@ class TestHelperDOCX
} }
/** /**
* Delete directory
*
* @param string $dir * @param string $dir
*/ */
public static function deleteDir($dir) public static function deleteDir($dir)
@ -63,6 +85,8 @@ class TestHelperDOCX
} }
/** /**
* Get file
*
* @return string * @return string
*/ */
public static function getFile() public static function getFile()

View File

@ -1,21 +1,50 @@
<?php <?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; namespace PhpOffice\PhpWord\Tests;
/**
* DOM wrapper class
*/
class XmlDocument class XmlDocument
{ {
/** @var string $path */ /**
* Path
*
* @var string $path
*/
private $path; private $path;
/** @var \DOMDocument $dom */ /**
* DOMDocument object
*
* @var \DOMDocument
*/
private $dom; private $dom;
/** @var \DOMXpath $xpath */ /**
* DOMXpath object
*
* @var \DOMXpath
*/
private $xpath; private $xpath;
/** @var string $file */ /**
* File name
*
* @var string
*/
private $file; private $file;
/** /**
* Create new instance
*
* @param string $path * @param string $path
*/ */
public function __construct($path) public function __construct($path)
@ -24,6 +53,8 @@ class XmlDocument
} }
/** /**
* Get DOM from file
*
* @param string $file * @param string $file
* @return \DOMDocument * @return \DOMDocument
*/ */
@ -43,9 +74,11 @@ class XmlDocument
} }
/** /**
* @param string $path * Get node list
* @param string $file *
* @return \DOMNodeList * @param string $path
* @param string $file
* @return \DOMNodeList
*/ */
public function getNodeList($path, $file = 'word/document.xml') public function getNodeList($path, $file = 'word/document.xml')
{ {
@ -62,9 +95,11 @@ class XmlDocument
} }
/** /**
* @param string $path * Get element
* @param string $file *
* @return \DOMElement * @param string $path
* @param string $file
* @return \DOMElement
*/ */
public function getElement($path, $file = 'word/document.xml') public function getElement($path, $file = 'word/document.xml')
{ {
@ -74,6 +109,8 @@ class XmlDocument
} }
/** /**
* Get file name
*
* @return string * @return string
*/ */
public function getFile() public function getFile()
@ -82,6 +119,8 @@ class XmlDocument
} }
/** /**
* Get path
*
* @return string * @return string
*/ */
public function getPath() public function getPath()
@ -90,6 +129,8 @@ class XmlDocument
} }
/** /**
* Get element attribute
*
* @param string $path * @param string $path
* @param string $attribute * @param string $attribute
* @param string $file * @param string $file
@ -101,6 +142,8 @@ class XmlDocument
} }
/** /**
* Check if element exists
*
* @param string $path * @param string $path
* @param string $file * @param string $file
* @return string * @return string

View File

@ -1,4 +1,12 @@
<?php <?php
/**
* PHPWord test bootstrap
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
// defining base dir for tests // defining base dir for tests
@ -24,7 +32,8 @@ spl_autoload_register(function ($class) {
$prefix = 'PhpOffice\\PhpWord\\Tests'; $prefix = 'PhpOffice\\PhpWord\\Tests';
if (strpos($class, $prefix) === 0) { if (strpos($class, $prefix) === 0) {
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class); $class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$class = 'PhpWord' . DIRECTORY_SEPARATOR . 'Tests' . DIRECTORY_SEPARATOR . '_includes' . substr($class, strlen($prefix)); $class = join(DIRECTORY_SEPARATOR, array('PhpWord', 'Tests', '_includes')) .
substr($class, strlen($prefix));
$file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php'; $file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php';
if (\file_exists($file)) { if (\file_exists($file)) {
require_once $file; require_once $file;