This commit is contained in:
Roman Syroeshko 2014-03-19 11:04:48 +04:00
parent 51ced7db8e
commit 4e546d1a21
47 changed files with 354 additions and 431 deletions

View File

@ -25,14 +25,14 @@
* @version 0.8.0 * @version 0.8.0
*/ */
namespace PhpOffice\PhpWord\Reader;
use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Exceptions\Exception;
/** /**
* PHPWord_Reader_Abstract * @codeCoverageIgnore Abstract class
*
* @codeCoverageIgnore Abstract class
*/ */
abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader abstract class AbstractReader implements IReader
{ {
/** /**
* Read data only? * Read data only?
@ -61,7 +61,7 @@ abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader
* Set read data only * Set read data only
* *
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Reader_IReader * @return PhpOffice\PhpWord\Reader\IReader
*/ */
public function setReadDataOnly($pValue = true) public function setReadDataOnly($pValue = true)
{ {
@ -91,7 +91,7 @@ abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader
} }
/** /**
* Can the current PHPWord_Reader_IReader read the file? * Can the current IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
* @return bool * @return bool

View File

@ -107,8 +107,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
// 'Title', 'TextRun'); // 'Title', 'TextRun');
// $i = 0; // $i = 0;
// foreach ($elementTypes as $elementType) { // foreach ($elementTypes as $elementType) {
// $objectType = "PHPWord_Section_{$elementType}"; // $this->assertInstanceOf("PhpOffice\\PhpWord\\Section\\{$elementType}", $elementCollection[$i]);
// $this->assertInstanceOf($objectType, $elementCollection[$i]);
// $i++; // $i++;
// } // }
} }

View File

@ -1,11 +1,9 @@
<?php <?php
namespace PHPWord\Tests\Shared; namespace PHPWord\Tests\Shared;
use PHPWord_Shared_Drawing; use PhpOffice\PhpWord\Shared\Drawing;
/** /**
* Class DrawingTest
*
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -21,28 +19,28 @@ class DrawingTest extends \PHPUnit_Framework_TestCase
$values[] = rand(1, 100); // integer $values[] = rand(1, 100); // integer
foreach ($values as $value) { foreach ($values as $value) {
$result = PHPWord_Shared_Drawing::pixelsToEMU($value); $result = Drawing::pixelsToEMU($value);
$this->assertEquals(round($value * 9525), $result); $this->assertEquals(round($value * 9525), $result);
$result = PHPWord_Shared_Drawing::EMUToPixels($value); $result = Drawing::EMUToPixels($value);
$this->assertEquals(round($value / 9525), $result); $this->assertEquals(round($value / 9525), $result);
$result = PHPWord_Shared_Drawing::pixelsToPoints($value); $result = Drawing::pixelsToPoints($value);
$this->assertEquals($value * 0.67777777, $result); $this->assertEquals($value * 0.67777777, $result);
$result = PHPWord_Shared_Drawing::pointsToPixels($value); $result = Drawing::pointsToPixels($value);
$this->assertEquals($value * 1.333333333, $result); $this->assertEquals($value * 1.333333333, $result);
$result = PHPWord_Shared_Drawing::degreesToAngle($value); $result = Drawing::degreesToAngle($value);
$this->assertEquals((int)round($value * 60000), $result); $this->assertEquals((int)round($value * 60000), $result);
$result = PHPWord_Shared_Drawing::angleToDegrees($value); $result = Drawing::angleToDegrees($value);
$this->assertEquals(round($value / 60000), $result); $this->assertEquals(round($value / 60000), $result);
$result = PHPWord_Shared_Drawing::pixelsToCentimeters($value); $result = Drawing::pixelsToCentimeters($value);
$this->assertEquals($value * 0.028, $result); $this->assertEquals($value * 0.028, $result);
$result = PHPWord_Shared_Drawing::centimetersToPixels($value); $result = Drawing::centimetersToPixels($value);
$this->assertEquals($value / 0.028, $result); $this->assertEquals($value / 0.028, $result);
} }
} }
@ -59,8 +57,8 @@ class DrawingTest extends \PHPUnit_Framework_TestCase
$values[] = array('0F9D', false); // 4 characters $values[] = array('0F9D', false); // 4 characters
// Conduct test // Conduct test
foreach ($values as $value) { foreach ($values as $value) {
$result = PHPWord_Shared_Drawing::htmlToRGB($value[0]); $result = Drawing::htmlToRGB($value[0]);
$this->assertEquals($value[1], $result); $this->assertEquals($value[1], $result);
} }
} }
} }

View File

@ -1,13 +1,11 @@
<?php <?php
namespace PHPWord\Tests\Shared; namespace PHPWord\Tests\Shared;
use PHPWord_Shared_File; use PhpOffice\PhpWord\Shared\File;
/** /**
* Class FileTest * @package PHPWord\Tests
* * @coversDefaultClass PhpOffice\PhpWord\Shared\File
* @package PHPWord\Tests
* @coversDefaultClass PHPWord_Shared_File
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class FileTest extends \PHPUnit_Framework_TestCase class FileTest extends \PHPUnit_Framework_TestCase
@ -17,26 +15,18 @@ class FileTest extends \PHPUnit_Framework_TestCase
*/ */
public function testFileExists() public function testFileExists()
{ {
$dir = join(DIRECTORY_SEPARATOR, array( $dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates'));
PHPWORD_TESTS_DIR_ROOT,
'_files',
'templates'
));
chdir($dir); chdir($dir);
$this->assertTrue(PHPWord_Shared_File::file_exists('blank.docx')); $this->assertTrue(File::file_exists('blank.docx'));
} }
/** /**
* Test file_exists() * Test file_exists()
*/ */
public function testNoFileExists() public function testNoFileExists()
{ {
$dir = join(DIRECTORY_SEPARATOR, array( $dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates'));
PHPWORD_TESTS_DIR_ROOT,
'_files',
'templates'
));
chdir($dir); chdir($dir);
$this->assertFalse(PHPWord_Shared_File::file_exists('404.docx')); $this->assertFalse(File::file_exists('404.docx'));
} }
/** /**
@ -44,14 +34,10 @@ class FileTest extends \PHPUnit_Framework_TestCase
*/ */
public function testRealpath() public function testRealpath()
{ {
$dir = join(DIRECTORY_SEPARATOR, array( $dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates'));
PHPWORD_TESTS_DIR_ROOT,
'_files',
'templates'
));
chdir($dir); chdir($dir);
$file = 'blank.docx'; $file = 'blank.docx';
$expected = $dir . DIRECTORY_SEPARATOR . $file; $expected = $dir . DIRECTORY_SEPARATOR . $file;
$this->assertEquals($expected, PHPWord_Shared_File::realpath($file)); $this->assertEquals($expected, File::realpath($file));
} }
} }

View File

@ -2,11 +2,9 @@
namespace PHPWord\Tests\Shared; namespace PHPWord\Tests\Shared;
use PHPWord; use PHPWord;
use PHPWord_Shared_Font; use PhpOffice\PhpWord\Shared\Font;
/** /**
* Class FontTest
*
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -21,25 +19,25 @@ class FontTest extends \PHPUnit_Framework_TestCase
$original = 1; $original = 1;
$result = PHPWord_Shared_Font::fontSizeToPixels($original); $result = Font::fontSizeToPixels($original);
$this->assertEquals($original * 16 / 12, $result); $this->assertEquals($original * 16 / 12, $result);
$result = PHPWord_Shared_Font::inchSizeToPixels($original); $result = Font::inchSizeToPixels($original);
$this->assertEquals($original * 96, $result); $this->assertEquals($original * 96, $result);
$result = PHPWord_Shared_Font::centimeterSizeToPixels($original); $result = Font::centimeterSizeToPixels($original);
$this->assertEquals($original * 37.795275591, $result); $this->assertEquals($original * 37.795275591, $result);
$result = PHPWord_Shared_Font::centimeterSizeToTwips($original); $result = Font::centimeterSizeToTwips($original);
$this->assertEquals($original * 565.217, $result); $this->assertEquals($original * 565.217, $result);
$result = PHPWord_Shared_Font::inchSizeToTwips($original); $result = Font::inchSizeToTwips($original);
$this->assertEquals($original * 565.217 * 2.54, $result); $this->assertEquals($original * 565.217 * 2.54, $result);
$result = PHPWord_Shared_Font::pixelSizeToTwips($original); $result = Font::pixelSizeToTwips($original);
$this->assertEquals($original * 565.217 / 37.795275591, $result); $this->assertEquals($original * 565.217 / 37.795275591, $result);
$result = PHPWord_Shared_Font::pointSizeToTwips($original); $result = Font::pointSizeToTwips($original);
$this->assertEquals($original * 20, $result); $this->assertEquals($original * 20, $result);
} }
} }

View File

@ -1,33 +1,31 @@
<?php <?php
namespace PHPWord\Tests\Shared; namespace PHPWord\Tests\Shared;
use PHPWord_Shared_String; use PhpOffice\PhpWord\Shared\String;
/** /**
* Class StringTest * @package PHPWord\Tests
* * @coversDefaultClass PhpOffice\PhpWord\Shared\String
* @package PHPWord\Tests
* @coversDefaultClass PHPWord_Shared_String
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class StringTest extends \PHPUnit_Framework_TestCase class StringTest extends \PHPUnit_Framework_TestCase
{ {
public function testIsUTF8() public function testIsUTF8()
{ {
$this->assertTrue(PHPWord_Shared_String::IsUTF8('')); $this->assertTrue(String::IsUTF8(''));
$this->assertTrue(PHPWord_Shared_String::IsUTF8('éééé')); $this->assertTrue(String::IsUTF8('éééé'));
$this->assertFalse(PHPWord_Shared_String::IsUTF8(utf8_decode('éééé'))); $this->assertFalse(String::IsUTF8(utf8_decode('éééé')));
} }
public function testControlCharacterOOXML2PHP() public function testControlCharacterOOXML2PHP()
{ {
$this->assertEquals('', PHPWord_Shared_String::ControlCharacterOOXML2PHP('')); $this->assertEquals('', String::ControlCharacterOOXML2PHP(''));
$this->assertEquals(chr(0x08), PHPWord_Shared_String::ControlCharacterOOXML2PHP('_x0008_')); $this->assertEquals(chr(0x08), String::ControlCharacterOOXML2PHP('_x0008_'));
} }
public function testControlCharacterPHP2OOXML() public function testControlCharacterPHP2OOXML()
{ {
$this->assertEquals('', PHPWord_Shared_String::ControlCharacterPHP2OOXML('')); $this->assertEquals('', String::ControlCharacterPHP2OOXML(''));
$this->assertEquals('_x0008_', PHPWord_Shared_String::ControlCharacterPHP2OOXML(chr(0x08))); $this->assertEquals('_x0008_', String::ControlCharacterPHP2OOXML(chr(0x08)));
} }
} }

View File

@ -1,11 +1,9 @@
<?php <?php
namespace PHPWord\Tests\Style; namespace PHPWord\Tests\Style;
use PHPWord_Style_Cell; use PhpOffice\PhpWord\Style\Cell;
/** /**
* Class CellTest
*
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -16,11 +14,11 @@ class CellTest extends \PHPUnit_Framework_TestCase
*/ */
public function testSetGetNormal() public function testSetGetNormal()
{ {
$object = new PHPWord_Style_Cell(); $object = new Cell();
$attributes = array( $attributes = array(
'valign' => 'left', 'valign' => 'left',
'textDirection' => PHPWord_Style_Cell::TEXT_DIR_BTLR, 'textDirection' => Cell::TEXT_DIR_BTLR,
'bgColor' => 'FFFF00', 'bgColor' => 'FFFF00',
'borderTopSize' => 120, 'borderTopSize' => 120,
'borderTopColor' => 'FFFF00', 'borderTopColor' => 'FFFF00',
@ -46,7 +44,7 @@ class CellTest extends \PHPUnit_Framework_TestCase
*/ */
public function testBorderColor() public function testBorderColor()
{ {
$object = new PHPWord_Style_Cell(); $object = new Cell();
$default = '000000'; $default = '000000';
$value = 'FF0000'; $value = 'FF0000';
@ -66,11 +64,11 @@ class CellTest extends \PHPUnit_Framework_TestCase
*/ */
public function testBorderSize() public function testBorderSize()
{ {
$object = new PHPWord_Style_Cell(); $object = new Cell();
$value = 120; $value = 120;
$expected = array($value, $value, $value, $value); $expected = array($value, $value, $value, $value);
$object->setStyleValue('_borderSize', $value); $object->setStyleValue('_borderSize', $value);
$this->assertEquals($expected, $object->getBorderSize()); $this->assertEquals($expected, $object->getBorderSize());
} }
} }

View File

@ -2,12 +2,10 @@
namespace PHPWord\Tests\Style; namespace PHPWord\Tests\Style;
use PHPWord; use PHPWord;
use PHPWord_Style_Font; use PhpOffice\PhpWord\Style\Font;
use PHPWord\Tests\TestHelperDOCX; use PHPWord\Tests\TestHelperDOCX;
/** /**
* Class FontTest
*
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -23,10 +21,10 @@ class FontTest extends \PHPUnit_Framework_TestCase
*/ */
public function testInitiation() public function testInitiation()
{ {
$object = new PHPWord_Style_Font('text', array('align' => 'both')); $object = new Font('text', array('align' => 'both'));
$this->assertEquals('text', $object->getStyleType()); $this->assertEquals('text', $object->getStyleType());
$this->assertInstanceOf('PHPWord_Style_Paragraph', $object->getParagraphStyle()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $object->getParagraphStyle());
} }
/** /**
@ -34,7 +32,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
*/ */
public function testSetStyleValueWithNullOrEmpty() public function testSetStyleValueWithNullOrEmpty()
{ {
$object = new PHPWord_Style_Font(); $object = new Font();
$attributes = array( $attributes = array(
'name' => PHPWord::DEFAULT_FONT_NAME, 'name' => PHPWord::DEFAULT_FONT_NAME,
@ -43,7 +41,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
'italic' => false, 'italic' => false,
'superScript' => false, 'superScript' => false,
'subScript' => false, 'subScript' => false,
'underline' => PHPWord_Style_Font::UNDERLINE_NONE, 'underline' => Font::UNDERLINE_NONE,
'strikethrough' => false, 'strikethrough' => false,
'color' => PHPWord::DEFAULT_FONT_COLOR, 'color' => PHPWord::DEFAULT_FONT_COLOR,
'fgColor' => null, 'fgColor' => null,
@ -62,7 +60,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
*/ */
public function testSetStyleValueNormal() public function testSetStyleValueNormal()
{ {
$object = new PHPWord_Style_Font(); $object = new Font();
$attributes = array( $attributes = array(
'name' => 'Times New Roman', 'name' => 'Times New Roman',
@ -71,7 +69,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
'italic' => true, 'italic' => true,
'superScript' => true, 'superScript' => true,
'subScript' => true, 'subScript' => true,
'underline' => PHPWord_Style_Font::UNDERLINE_HEAVY, 'underline' => Font::UNDERLINE_HEAVY,
'strikethrough' => true, 'strikethrough' => true,
'color' => '999999', 'color' => '999999',
'fgColor' => '999999', 'fgColor' => '999999',
@ -113,4 +111,4 @@ class FontTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(720, $lineHeight); $this->assertEquals(720, $lineHeight);
$this->assertEquals('auto', $lineRule); $this->assertEquals('auto', $lineRule);
} }
} }

View File

@ -1,11 +1,9 @@
<?php <?php
namespace PHPWord\Tests\Style; namespace PHPWord\Tests\Style;
use PHPWord_Style_Image; use PhpOffice\PhpWord\Style\Image;
/** /**
* Class ImageTest
*
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -16,7 +14,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
*/ */
public function testSetGetNormal() public function testSetGetNormal()
{ {
$object = new PHPWord_Style_Image(); $object = new Image();
$properties = array( $properties = array(
'width' => 200, 'width' => 200,
@ -39,7 +37,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
*/ */
public function testSetStyleValue() public function testSetStyleValue()
{ {
$object = new PHPWord_Style_Image(); $object = new Image();
$properties = array( $properties = array(
'width' => 200, 'width' => 200,
@ -62,7 +60,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
*/ */
public function testSetWrappingStyleException() public function testSetWrappingStyleException()
{ {
$object = new PHPWord_Style_Image(); $object = new Image();
$object->setWrappingStyle('foo'); $object->setWrappingStyle('foo');
} }
} }

View File

@ -1,11 +1,9 @@
<?php <?php
namespace PHPWord\Tests\Style; namespace PHPWord\Tests\Style;
use PHPWord_Style_ListItem; use PhpOffice\PhpWord\Style\ListItem;
/** /**
* Class ListItemTest
*
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -16,9 +14,9 @@ class ListItemTest extends \PHPUnit_Framework_TestCase
*/ */
public function testConstruct() public function testConstruct()
{ {
$object = new PHPWord_Style_ListItem(); $object = new ListItem();
$value = PHPWord_Style_ListItem::TYPE_BULLET_FILLED; $value = ListItem::TYPE_BULLET_FILLED;
$this->assertEquals($value, $object->getListType()); $this->assertEquals($value, $object->getListType());
} }
@ -27,9 +25,9 @@ class ListItemTest extends \PHPUnit_Framework_TestCase
*/ */
public function testSetStyleValue() public function testSetStyleValue()
{ {
$object = new PHPWord_Style_ListItem(); $object = new ListItem();
$value = PHPWord_Style_ListItem::TYPE_ALPHANUM; $value = ListItem::TYPE_ALPHANUM;
$object->setStyleValue('_listType', $value); $object->setStyleValue('_listType', $value);
$this->assertEquals($value, $object->getListType()); $this->assertEquals($value, $object->getListType());
} }
@ -39,10 +37,10 @@ class ListItemTest extends \PHPUnit_Framework_TestCase
*/ */
public function testListType() public function testListType()
{ {
$object = new PHPWord_Style_ListItem(); $object = new ListItem();
$value = PHPWord_Style_ListItem::TYPE_ALPHANUM; $value = ListItem::TYPE_ALPHANUM;
$object->setListType($value); $object->setListType($value);
$this->assertEquals($value, $object->getListType()); $this->assertEquals($value, $object->getListType());
} }
} }

View File

@ -2,13 +2,11 @@
namespace PHPWord\Tests\Style; namespace PHPWord\Tests\Style;
use PHPWord; use PHPWord;
use PHPWord_Style_Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
use PHPWord_Style_Tab; use PhpOffice\PhpWord\Style\Tab;
use PHPWord\Tests\TestHelperDOCX; use PHPWord\Tests\TestHelperDOCX;
/** /**
* Class ParagraphTest
*
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -24,7 +22,7 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
*/ */
public function testSetStyleValueWithNullOrEmpty() public function testSetStyleValueWithNullOrEmpty()
{ {
$object = new PHPWord_Style_Paragraph(); $object = new Paragraph();
$attributes = array( $attributes = array(
'tabs' => null, 'tabs' => null,
@ -47,7 +45,7 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
*/ */
public function testSetStyleValueNormal() public function testSetStyleValueNormal()
{ {
$object = new PHPWord_Style_Paragraph(); $object = new Paragraph();
$attributes = array( $attributes = array(
'align' => 'justify', 'align' => 'justify',
@ -84,12 +82,9 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
*/ */
public function testTabs() public function testTabs()
{ {
$object = new PHPWord_Style_Paragraph(); $object = new Paragraph();
$object->setTabs(array( $object->setTabs(array(new Tab('left', 1550), new Tab('right', 5300)));
new PHPWord_Style_Tab('left', 1550), $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Tabs', $object->getTabs());
new PHPWord_Style_Tab('right', 5300),
));
$this->assertInstanceOf('PHPWord_Style_Tabs', $object->getTabs());
} }
public function testLineHeight() public function testLineHeight()
@ -128,8 +123,8 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
*/ */
public function testLineHeightValidation() public function testLineHeightValidation()
{ {
$object = new PHPWord_Style_Paragraph(); $object = new Paragraph();
$object->setLineHeight('12.5pt'); $object->setLineHeight('12.5pt');
$this->assertEquals(12.5, $object->getLineHeight()); $this->assertEquals(12.5, $object->getLineHeight());
} }
} }

View File

@ -1,11 +1,9 @@
<?php <?php
namespace PHPWord\Tests\Style; namespace PHPWord\Tests\Style;
use PHPWord_Style_Row; use PhpOffice\PhpWord\Style\Row;
/** /**
* Class RowTest
*
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -16,7 +14,7 @@ class RowTest extends \PHPUnit_Framework_TestCase
*/ */
public function testProperties() public function testProperties()
{ {
$object = new PHPWord_Style_Row(); $object = new Row();
$properties = array( $properties = array(
'tblHeader' => true, 'tblHeader' => true,
@ -37,4 +35,4 @@ class RowTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expected, $object->$get()); $this->assertEquals($expected, $object->$get());
} }
} }
} }

View File

@ -1,13 +1,11 @@
<?php <?php
namespace PHPWord\Tests\Style; namespace PHPWord\Tests\Style;
use PHPWord_Style_TOC; use PhpOffice\PhpWord\Style\TOC;
/** /**
* Class TOCTest * @package PHPWord\Tests
* * @coversDefaultClass PhpOffice\PhpWord\Style\TOC
* @package PHPWord\Tests
* @covers PHPWord_Style_TOC
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class TOCTest extends \PHPUnit_Framework_TestCase class TOCTest extends \PHPUnit_Framework_TestCase
@ -17,11 +15,11 @@ class TOCTest extends \PHPUnit_Framework_TestCase
*/ */
public function testProperties() public function testProperties()
{ {
$object = new PHPWord_Style_TOC(); $object = new TOC();
$properties = array( $properties = array(
'tabPos' => 9062, 'tabPos' => 9062,
'tabLeader' => PHPWord_Style_TOC::TABLEADER_DOT, 'tabLeader' => TOC::TABLEADER_DOT,
'indent' => 200, 'indent' => 200,
); );
foreach ($properties as $key => $value) { foreach ($properties as $key => $value) {
@ -36,4 +34,4 @@ class TOCTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(null, $object->$get()); $this->assertEquals(null, $object->$get());
} }
} }
} }

View File

@ -1,11 +1,9 @@
<?php <?php
namespace PHPWord\Tests\Style; namespace PHPWord\Tests\Style;
use PHPWord_Style_TableFull; use PhpOffice\PhpWord\Style\TableFull;
/** /**
* Class TableFullTest
*
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -24,11 +22,11 @@ class TableFullTest extends \PHPUnit_Framework_TestCase
$styleTable = array('bgColor' => 'FF0000'); $styleTable = array('bgColor' => 'FF0000');
$styleFirstRow = array('borderBottomSize' => 3); $styleFirstRow = array('borderBottomSize' => 3);
$object = new PHPWord_Style_TableFull($styleTable, $styleFirstRow); $object = new TableFull($styleTable, $styleFirstRow);
$this->assertEquals('FF0000', $object->getBgColor()); $this->assertEquals('FF0000', $object->getBgColor());
$firstRow = $object->getFirstRow(); $firstRow = $object->getFirstRow();
$this->assertInstanceOf('PHPWord_Style_TableFull', $firstRow); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\TableFull', $firstRow);
$this->assertEquals(3, $firstRow->getBorderBottomSize()); $this->assertEquals(3, $firstRow->getBorderBottomSize());
} }
@ -37,7 +35,7 @@ class TableFullTest extends \PHPUnit_Framework_TestCase
*/ */
public function testSetGetNormal() public function testSetGetNormal()
{ {
$object = new PHPWord_Style_TableFull(); $object = new TableFull();
$attributes = array( $attributes = array(
'bgColor' => 'FF0000', 'bgColor' => 'FF0000',
@ -74,7 +72,7 @@ class TableFullTest extends \PHPUnit_Framework_TestCase
*/ */
public function testBorderColor() public function testBorderColor()
{ {
$object = new PHPWord_Style_TableFull(); $object = new TableFull();
$parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV'); $parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV');
$value = 'FF0000'; $value = 'FF0000';
@ -96,7 +94,7 @@ class TableFullTest extends \PHPUnit_Framework_TestCase
*/ */
public function testBorderSize() public function testBorderSize()
{ {
$object = new PHPWord_Style_TableFull(); $object = new TableFull();
$parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV'); $parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV');
$value = 4; $value = 4;
@ -118,7 +116,7 @@ class TableFullTest extends \PHPUnit_Framework_TestCase
*/ */
public function testCellMargin() public function testCellMargin()
{ {
$object = new PHPWord_Style_TableFull(); $object = new TableFull();
$parts = array('Top', 'Left', 'Right', 'Bottom'); $parts = array('Top', 'Left', 'Right', 'Bottom');
$value = 240; $value = 240;
@ -130,4 +128,4 @@ class TableFullTest extends \PHPUnit_Framework_TestCase
} }
$this->assertEquals($values, $object->getCellMargin()); $this->assertEquals($values, $object->getCellMargin());
} }
} }

View File

@ -1,11 +1,9 @@
<?php <?php
namespace PHPWord\Tests\Style; namespace PHPWord\Tests\Style;
use PHPWord_Style_Table; use PhpOffice\PhpWord\Style\Table;
/** /**
* Class TableTest
*
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -16,7 +14,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
*/ */
public function testSetStyleValue() public function testSetStyleValue()
{ {
$object = new PHPWord_Style_Table(); $object = new Table();
$parts = array('Top', 'Left', 'Right', 'Bottom'); $parts = array('Top', 'Left', 'Right', 'Bottom');
$value = 240; // In twips $value = 240; // In twips
@ -33,7 +31,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
*/ */
public function testCellMargin() public function testCellMargin()
{ {
$object = new PHPWord_Style_Table(); $object = new Table();
$parts = array('Top', 'Left', 'Right', 'Bottom'); $parts = array('Top', 'Left', 'Right', 'Bottom');
// Set cell margin and test if each part has the same margin // Set cell margin and test if each part has the same margin
@ -48,4 +46,4 @@ class TableTest extends \PHPUnit_Framework_TestCase
} }
$this->assertEquals($values, $object->getCellMargin()); $this->assertEquals($values, $object->getCellMargin());
} }
} }

View File

@ -2,13 +2,10 @@
namespace PHPWord\Tests\Style; namespace PHPWord\Tests\Style;
use PHPWord; use PHPWord;
use PHPWord_Style_Tab; use PhpOffice\PhpWord\Style\Tab;
use PHPWord_Style_Tabs;
use PHPWord\Tests\TestHelperDOCX; use PHPWord\Tests\TestHelperDOCX;
/** /**
* Class TabsTest
*
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -28,11 +25,7 @@ class TabsTest extends \PHPUnit_Framework_TestCase
public function testTabsStyle() public function testTabsStyle()
{ {
$PHPWord = new PHPWord(); $PHPWord = new PHPWord();
$PHPWord->addParagraphStyle('tabbed', array( $PHPWord->addParagraphStyle('tabbed', array('tabs' => array(new Tab('left', 1440, 'dot'))));
'tabs' => array(
new PHPWord_Style_Tab('left', 1440, 'dot'),
)
));
$doc = TestHelperDOCX::getDocument($PHPWord); $doc = TestHelperDOCX::getDocument($PHPWord);
$file = 'word/styles.xml'; $file = 'word/styles.xml';
$path = '/w:styles/w:style[@w:styleId="tabbed"]/w:pPr/w:tabs/w:tab[1]'; $path = '/w:styles/w:style[@w:styleId="tabbed"]/w:pPr/w:tabs/w:tab[1]';
@ -41,4 +34,4 @@ class TabsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(1440, $element->getAttribute('w:pos')); $this->assertEquals(1440, $element->getAttribute('w:pos'));
$this->assertEquals('dot', $element->getAttribute('w:leader')); $this->assertEquals('dot', $element->getAttribute('w:leader'));
} }
} }

View File

@ -1,22 +1,20 @@
<?php <?php
namespace PHPWord\Tests; namespace PHPWord\Tests;
use PHPWord_Style; use PhpOffice\PhpWord\Style;
/** /**
* Class StyleTest * @package PHPWord\Tests
* * @coversDefaultClass PhpOffice\PhpWord\Style
* @package PHPWord\Tests
* @covers PHPWord_Style
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class StyleTest extends \PHPUnit_Framework_TestCase class StyleTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @covers PHPWord_Style::addParagraphStyle * @covers ::addParagraphStyle
* @covers PHPWord_Style::addFontStyle * @covers ::addFontStyle
* @covers PHPWord_Style::addLinkStyle * @covers ::addLinkStyle
* @covers PHPWord_Style::addTitleStyle * @covers ::addTitleStyle
*/ */
public function testStyles() public function testStyles()
{ {
@ -27,18 +25,17 @@ class StyleTest extends \PHPUnit_Framework_TestCase
'Link' => 'Font', 'Table' => 'TableFull', 'Link' => 'Font', 'Table' => 'TableFull',
'Heading_1' => 'Font', 'Normal' => 'Paragraph'); 'Heading_1' => 'Font', 'Normal' => 'Paragraph');
$elementCount = 6; $elementCount = 6;
PHPWord_Style::addParagraphStyle('Paragraph', $paragraph); Style::addParagraphStyle('Paragraph', $paragraph);
PHPWord_Style::addFontStyle('Font', $font); Style::addFontStyle('Font', $font);
PHPWord_Style::addLinkStyle('Link', $font); Style::addLinkStyle('Link', $font);
PHPWord_Style::addTableStyle('Table', $table); Style::addTableStyle('Table', $table);
PHPWord_Style::addTitleStyle(1, $font); Style::addTitleStyle(1, $font);
PHPWord_Style::setDefaultParagraphStyle($paragraph); Style::setDefaultParagraphStyle($paragraph);
$this->assertEquals($elementCount, count(PHPWord_Style::getStyles())); $this->assertEquals($elementCount, count(Style::getStyles()));
foreach ($styles as $name => $style) { foreach ($styles as $name => $style) {
$expected = "PHPWord_Style_{$style}"; $this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$style}", Style::getStyle($name));
$this->assertInstanceOf($expected, PHPWord_Style::getStyle($name));
} }
$this->assertNull(PHPWord_Style::getStyle('Unknown')); $this->assertNull(Style::getStyle('Unknown'));
} }
} }

View File

@ -1,38 +1,35 @@
<?php <?php
namespace PHPWord\Tests; namespace PHPWord\Tests;
use PHPWord_TOC; use PhpOffice\PhpWord\TOC;
use PHPWord_Style_TOC;
/** /**
* Class TOCTest * @package PHPWord\Tests
* * @coversDefaultClass PhpOffice\PhpWord\TOC
* @package PHPWord\Tests
* @covers PHPWord_TOC
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class TOCTest extends \PHPUnit_Framework_TestCase class TOCTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @covers PHPWord_TOC::__construct * @covers ::__construct
* @covers PHPWord_TOC::getStyleTOC * @covers ::getStyleTOC
* @covers PHPWord_TOC::getStyleFont * @covers ::getStyleFont
*/ */
public function testConstruct() public function testConstruct()
{ {
$expected = array( $expected = array(
'tabPos' => 9062, 'tabPos' => 9062,
'tabLeader' => PHPWord_Style_TOC::TABLEADER_DOT, 'tabLeader' => PhpOffice\PhpWord\Style\TOC::TABLEADER_DOT,
'indent' => 200, 'indent' => 200,
); );
$object = new PHPWord_TOC( $object = new TOC(
array('size' => 11), array('size' => 11),
array('tabPos' => $expected['tabPos']) array('tabPos' => $expected['tabPos'])
); );
$tocStyle = $object->getStyleTOC(); $tocStyle = $object->getStyleTOC();
$this->assertInstanceOf('PHPWord_Style_TOC', $tocStyle); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\TOC', $tocStyle);
$this->assertInstanceOf('PHPWord_Style_Font', $object->getStyleFont()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $object->getStyleFont());
foreach ($expected as $key => $value) { foreach ($expected as $key => $value) {
$method = "get{$key}"; $method = "get{$key}";
@ -41,8 +38,8 @@ class TOCTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* @covers PHPWord_TOC::addTitle * @covers ::addTitle
* @covers PHPWord_TOC::getTitles * @covers ::getTitles
*/ */
public function testAddAndGetTitle() public function testAddAndGetTitle()
{ {
@ -56,20 +53,20 @@ class TOCTest extends \PHPUnit_Framework_TestCase
'Heading 3' => 3, 'Heading 3' => 3,
); );
// @covers PHPWord_TOC::addTitle // @covers ::addTitle
foreach ($titles as $text => $depth) { foreach ($titles as $text => $depth) {
$response = PHPWord_TOC::addTitle($text, $depth); $response = TOC::addTitle($text, $depth);
} }
$this->assertEquals($anchor, $response[0]); $this->assertEquals($anchor, $response[0]);
$this->assertEquals($bookmark, $response[1]); $this->assertEquals($bookmark, $response[1]);
// @covers PHPWord_TOC::getTitles // @covers ::getTitles
$i = 0; $i = 0;
$savedTitles = PHPWord_TOC::getTitles(); $savedTitles = TOC::getTitles();
foreach ($titles as $text => $depth) { foreach ($titles as $text => $depth) {
$this->assertEquals($text, $savedTitles[$i]['text']); $this->assertEquals($text, $savedTitles[$i]['text']);
$this->assertEquals($depth, $savedTitles[$i]['depth']); $this->assertEquals($depth, $savedTitles[$i]['depth']);
$i++; $i++;
} }
} }
} }

View File

@ -1,11 +1,11 @@
<?php <?php
namespace PHPWord\Tests; namespace PHPWord\Tests;
use PHPWord_Template; use PhpOffice\PhpWord\Template;
use PHPWord; use PHPWord;
/** /**
* @coversDefaultClass PHPWord_Template * @coversDefaultClass PhpOffice\PhpWord\Template
*/ */
final class TemplateTest extends \PHPUnit_Framework_TestCase final class TemplateTest extends \PHPUnit_Framework_TestCase
{ {
@ -20,7 +20,7 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'with_table_macros.docx') array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'with_table_macros.docx')
); );
$document = new PHPWord_Template($templateFqfn); $document = new Template($templateFqfn);
$xslDOMDocument = new \DOMDocument(); $xslDOMDocument = new \DOMDocument();
$xslDOMDocument->load( $xslDOMDocument->load(
\join( \join(
@ -93,7 +93,7 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase
*/ */
final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue() final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue()
{ {
$template = new PHPWord_Template( $template = new Template(
\join( \join(
\DIRECTORY_SEPARATOR, \DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx') array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx')
@ -123,7 +123,7 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase
*/ */
final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplate() final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplate()
{ {
$template = new PHPWord_Template( $template = new Template(
\join( \join(
\DIRECTORY_SEPARATOR, \DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'corrupted_main_document_part.docx') array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'corrupted_main_document_part.docx')

View File

@ -2,14 +2,11 @@
namespace PHPWord\Tests\Writer\ODText; namespace PHPWord\Tests\Writer\ODText;
use PHPWord; use PHPWord;
use PHPWord_Style;
use PHPWord\Tests\TestHelperDOCX; use PHPWord\Tests\TestHelperDOCX;
/** /**
* Class ContentTest * @package PHPWord\Tests
* * @coversDefaultClass PhpOffice\PhpWord\Writer\ODText\Content
* @package PHPWord\Tests
* @coversDefaultClass PHPWord_Writer_ODText_Content
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class ContentTest extends \PHPUnit_Framework_TestCase class ContentTest extends \PHPUnit_Framework_TestCase
@ -23,8 +20,8 @@ class ContentTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::writeContent * covers ::writeContent
* covers <private> * covers <private>
*/ */
public function testWriteContent() public function testWriteContent()
{ {
@ -62,4 +59,4 @@ class ContentTest extends \PHPUnit_Framework_TestCase
$element = "/office:document-content/office:body/office:text/text:p"; $element = "/office:document-content/office:body/office:text/text:p";
$this->assertEquals($expected, $doc->getElement($element, 'content.xml')->nodeValue); $this->assertEquals($expected, $doc->getElement($element, 'content.xml')->nodeValue);
} }
} }

View File

@ -1,14 +1,12 @@
<?php <?php
namespace PHPWord\Tests\Writer; namespace PHPWord\Tests\Writer;
use PHPWord_Writer_ODText; use PhpOffice\PhpWord\Writer\ODText;
use PHPWord; use PHPWord;
/** /**
* Class ODTextTest * @package PHPWord\Tests
* * @coversDefaultClass PhpOffice\PhpWord\Writer\ODText
* @package PHPWord\Tests
* @coversDefaultClass PHPWord_Writer_ODText
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class ODTextTest extends \PHPUnit_Framework_TestCase class ODTextTest extends \PHPUnit_Framework_TestCase
@ -18,38 +16,37 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
*/ */
public function testConstruct() public function testConstruct()
{ {
$object = new PHPWord_Writer_ODText(new PHPWord()); $object = new ODText(new PHPWord());
$this->assertInstanceOf('PHPWord', $object->getPHPWord()); $this->assertInstanceOf('PhpOffice\\PHPWord', $object->getPHPWord());
$this->assertInstanceOf("PHPWord_HashTable", $object->getDrawingHashTable()); $this->assertInstanceOf('PhpOffice\\PhpWord\\HashTable', $object->getDrawingHashTable());
$this->assertEquals('./', $object->getDiskCachingDirectory()); $this->assertEquals('./', $object->getDiskCachingDirectory());
$writerParts = array('Content', 'Manifest', 'Meta', 'Mimetype', 'Styles'); foreach (array('Content', 'Manifest', 'Meta', 'Mimetype', 'Styles') as $part) {
foreach ($writerParts as $part) {
$this->assertInstanceOf( $this->assertInstanceOf(
"PHPWord_Writer_ODText_{$part}", "PhpOffice\\PhpWord\\Writer\\ODText\\{$part}",
$object->getWriterPart($part) $object->getWriterPart($part)
); );
$this->assertInstanceOf( $this->assertInstanceOf(
"PHPWord_Writer_ODText", 'PhpOffice\\PhpWord\\Writer\\ODText',
$object->getWriterPart($part)->getParentWriter() $object->getWriterPart($part)->getParentWriter()
); );
} }
} }
/** /**
* @covers ::getPHPWord * @covers ::getPHPWord
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessage No PHPWord assigned. * @expectedExceptionMessage No PHPWord assigned.
*/ */
public function testConstructWithNull() public function testConstructWithNull()
{ {
$object = new PHPWord_Writer_ODText(); $object = new ODText();
$object->getPHPWord(); $object->getPHPWord();
} }
/** /**
* @covers ::save * @covers ::save
*/ */
public function testSave() public function testSave()
{ {
@ -84,7 +81,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
$section = $phpWord->createSection(); $section = $phpWord->createSection();
$textrun = $section->createTextRun(); $textrun = $section->createTextRun();
$textrun->addText('Test 3'); $textrun->addText('Test 3');
$writer = new PHPWord_Writer_ODText($phpWord); $writer = new ODText($phpWord);
$writer->save($file); $writer->save($file);
$this->assertTrue(file_exists($file)); $this->assertTrue(file_exists($file));
@ -93,53 +90,53 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* @covers ::save * @covers ::save
* @todo Haven't got any method to test this * @todo Haven't got any method to test this
*/ */
public function testSavePhpOutput() public function testSavePhpOutput()
{ {
$phpWord = new PHPWord(); $phpWord = new PHPWord();
$section = $phpWord->createSection(); $section = $phpWord->createSection();
$section->addText('Test'); $section->addText('Test');
$writer = new PHPWord_Writer_ODText($phpWord); $writer = new ODText($phpWord);
$writer->save('php://output'); $writer->save('php://output');
} }
/** /**
* @covers ::save * @covers ::save
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessage PHPWord object unassigned. * @expectedExceptionMessage PHPWord object unassigned.
*/ */
public function testSaveException() public function testSaveException()
{ {
$writer = new PHPWord_Writer_ODText(); $writer = new ODText();
$writer->save(); $writer->save();
} }
/** /**
* @covers ::getWriterPart * @covers ::getWriterPart
*/ */
public function testGetWriterPartNull() public function testGetWriterPartNull()
{ {
$object = new PHPWord_Writer_ODText(); $object = new ODText();
$this->assertNull($object->getWriterPart('foo')); $this->assertNull($object->getWriterPart('foo'));
} }
/** /**
* @covers ::setUseDiskCaching * @covers ::setUseDiskCaching
* @covers ::getUseDiskCaching * @covers ::getUseDiskCaching
*/ */
public function testSetGetUseDiskCaching() public function testSetGetUseDiskCaching()
{ {
$object = new PHPWord_Writer_ODText(); $object = new ODText();
$object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT); $object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT);
$this->assertTrue($object->getUseDiskCaching()); $this->assertTrue($object->getUseDiskCaching());
$this->assertEquals(PHPWORD_TESTS_DIR_ROOT, $object->getDiskCachingDirectory()); $this->assertEquals(PHPWORD_TESTS_DIR_ROOT, $object->getDiskCachingDirectory());
} }
/** /**
* @covers ::setUseDiskCaching * @covers ::setUseDiskCaching
* @expectedException Exception * @expectedException Exception
*/ */
public function testSetUseDiskCachingException() public function testSetUseDiskCachingException()
{ {
@ -148,7 +145,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
array(\PHPWORD_TESTS_DIR_ROOT, 'foo') array(\PHPWORD_TESTS_DIR_ROOT, 'foo')
); );
$object = new PHPWord_Writer_ODText($phpWord); $object = new ODText($phpWord);
$object->setUseDiskCaching(true, $dir); $object->setUseDiskCaching(true, $dir);
} }
} }

View File

@ -1,67 +1,65 @@
<?php <?php
namespace PHPWord\Tests\Writer; namespace PHPWord\Tests\Writer;
use PHPWord_Writer_RTF; use PhpOffice\PhpWord\Writer\RTF;
use PHPWord; use PHPWord;
/** /**
* Class RTFTest * @package PHPWord\Tests
* * @coversDefaultClass PhpOffice\PhpWord\Writer\RTF
* @package PHPWord\Tests
* @coversDefaultClass PHPWord_Writer_RTF
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class RTFTest extends \PHPUnit_Framework_TestCase class RTFTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* covers ::construct * covers ::construct
*/ */
public function testConstruct() public function testConstruct()
{ {
$object = new PHPWord_Writer_RTF(new PHPWord); $object = new RTF(new PHPWord);
$this->assertInstanceOf('PHPWord', $object->getPHPWord()); $this->assertInstanceOf('PhpOffice\\PHPWord', $object->getPHPWord());
$this->assertInstanceOf("PHPWord_HashTable", $object->getDrawingHashTable()); $this->assertInstanceOf('PhpOffice\\PhpWord\\HashTable', $object->getDrawingHashTable());
} }
/** /**
* covers ::__construct * covers ::__construct
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessage No PHPWord assigned. * @expectedExceptionMessage No PHPWord assigned.
*/ */
public function testConstructWithNull() public function testConstructWithNull()
{ {
$object = new PHPWord_Writer_RTF(); $object = new RTF();
$object->getPHPWord(); $object->getPHPWord();
} }
/** /**
* @covers ::save * @covers ::save
* @todo Haven't got any method to test this * @todo Haven't got any method to test this
*/ */
public function testSavePhpOutput() public function testSavePhpOutput()
{ {
$phpWord = new PHPWord(); $phpWord = new PHPWord();
$section = $phpWord->createSection(); $section = $phpWord->createSection();
$section->addText('Test'); $section->addText('Test');
$writer = new PHPWord_Writer_RTF($phpWord); $writer = new RTF($phpWord);
$writer->save('php://output'); $writer->save('php://output');
} }
/** /**
* @covers ::save * @covers ::save
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessage PHPWord object unassigned. * @expectedExceptionMessage PHPWord object unassigned.
*/ */
public function testSaveException() public function testSaveException()
{ {
$writer = new PHPWord_Writer_RTF(); $writer = new RTF();
$writer->save(); $writer->save();
} }
/** /**
* @covers ::save * @covers ::save
* @covers ::<private> * @covers ::<private>
*/ */
public function testSave() public function testSave()
{ {
@ -97,11 +95,11 @@ class RTFTest extends \PHPUnit_Framework_TestCase
$textrun = $section->createTextRun(); $textrun = $section->createTextRun();
$textrun->addText('Test 3'); $textrun->addText('Test 3');
$textrun->addTextBreak(); $textrun->addTextBreak();
$writer = new PHPWord_Writer_RTF($phpWord); $writer = new RTF($phpWord);
$writer->save($file); $writer->save($file);
$this->assertTrue(file_exists($file)); $this->assertTrue(file_exists($file));
unlink($file); unlink($file);
} }
} }

View File

@ -2,14 +2,11 @@
namespace PHPWord\Tests\Writer\Word2007; namespace PHPWord\Tests\Writer\Word2007;
use PHPWord; use PHPWord;
use PHPWord_Style;
use PHPWord\Tests\TestHelperDOCX; use PHPWord\Tests\TestHelperDOCX;
/** /**
* Class BaseTest * @package PHPWord\Tests
* * @coversDefaultClass PhpOffice\PhpWord\Writer\Word2007\Base
* @package PHPWord\Tests
* @coversDefaultClass PHPWord_Writer_Word2007_Base
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class BaseTest extends \PHPUnit_Framework_TestCase class BaseTest extends \PHPUnit_Framework_TestCase
@ -23,7 +20,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::_writeText * covers ::_writeText
*/ */
public function testWriteText() public function testWriteText()
{ {
@ -44,7 +41,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::_writeTextRun * covers ::_writeTextRun
*/ */
public function testWriteTextRun() public function testWriteTextRun()
{ {
@ -71,7 +68,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::_writeLink * covers ::_writeLink
*/ */
public function testWriteLink() public function testWriteLink()
{ {
@ -88,7 +85,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::_writePreserveText * covers ::_writePreserveText
*/ */
public function testWritePreserveText() public function testWritePreserveText()
{ {
@ -104,8 +101,9 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('PAGE', $preserve->nodeValue); $this->assertEquals('PAGE', $preserve->nodeValue);
$this->assertEquals('preserve', $preserve->getAttribute('xml:space')); $this->assertEquals('preserve', $preserve->getAttribute('xml:space'));
} }
/** /**
* covers ::_writeTextBreak * covers ::_writeTextBreak
*/ */
public function testWriteTextBreak() public function testWriteTextBreak()
{ {
@ -130,7 +128,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::_writeParagraphStyle * covers ::_writeParagraphStyle
*/ */
public function testWriteParagraphStyleAlign() public function testWriteParagraphStyleAlign()
{ {
@ -146,7 +144,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::_writeParagraphStyle * covers ::_writeParagraphStyle
*/ */
public function testWriteParagraphStylePagination() public function testWriteParagraphStylePagination()
{ {
@ -176,7 +174,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::_writeTextStyle * covers ::_writeTextStyle
*/ */
public function testWriteFontStyle() public function testWriteFontStyle()
{ {
@ -208,7 +206,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::_writeTableStyle * covers ::_writeTableStyle
*/ */
public function testWriteTableStyle() public function testWriteTableStyle()
{ {
@ -266,7 +264,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::_writeCellStyle * covers ::_writeCellStyle
*/ */
public function testWriteCellStyleCellGridSpan() public function testWriteCellStyleCellGridSpan()
{ {
@ -293,7 +291,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::_writeImage * covers ::_writeImage
*/ */
public function testWriteImagePosition() public function testWriteImagePosition()
{ {
@ -318,7 +316,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::_writeWatermark * covers ::_writeWatermark
*/ */
public function testWriteWatermark() public function testWriteWatermark()
{ {
@ -338,7 +336,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::_writeTitle * covers ::_writeTitle
*/ */
public function testWriteTitle() public function testWriteTitle()
{ {
@ -352,4 +350,4 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$element = "/w:document/w:body/w:p/w:r/w:fldChar"; $element = "/w:document/w:body/w:p/w:r/w:fldChar";
$this->assertEquals('end', $doc->getElementAttribute($element, 'w:fldCharType')); $this->assertEquals('end', $doc->getElementAttribute($element, 'w:fldCharType'));
} }
} }

View File

@ -2,12 +2,9 @@
namespace PHPWord\Tests\Writer\Word2007; namespace PHPWord\Tests\Writer\Word2007;
use PHPWord; use PHPWord;
use PHPWord_Writer_Word2007;
use PHPWord_Writer_Word2007_Document;
use PHPWord\Tests\TestHelperDOCX; use PHPWord\Tests\TestHelperDOCX;
/** /**
* Class DocumentTest
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -34,11 +31,11 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::_writeTOC * covers ::_writeTOC
* covers ::_writePageBreak * covers ::_writePageBreak
* covers ::_writeListItem * covers ::_writeListItem
* covers ::_writeTitle * covers ::_writeTitle
* covers ::_writeObject * covers ::_writeObject
*/ */
public function testElements() public function testElements()
{ {
@ -84,4 +81,4 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$element = $doc->getElement('/w:document/w:body/w:p[11]/w:r/w:object/o:OLEObject'); $element = $doc->getElement('/w:document/w:body/w:p[11]/w:r/w:object/o:OLEObject');
$this->assertEquals('Embed', $element->getAttribute('Type')); $this->assertEquals('Embed', $element->getAttribute('Type'));
} }
} }

View File

@ -5,7 +5,6 @@ use PHPWord;
use PHPWord\Tests\TestHelperDOCX; use PHPWord\Tests\TestHelperDOCX;
/** /**
* Class PHPWord_Writer_Word2007_FootnotesTest
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -31,4 +30,4 @@ class FootnotesTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($doc->elementExists("/w:document/w:body/w:p/w:r/w:footnoteReference")); $this->assertTrue($doc->elementExists("/w:document/w:body/w:p/w:r/w:footnoteReference"));
} }
} }

View File

@ -5,7 +5,6 @@ use PHPWord;
use PHPWord\Tests\TestHelperDOCX; use PHPWord\Tests\TestHelperDOCX;
/** /**
* Class PHPWord_Writer_Word2007_StylesTest
* @package PHPWord\Tests * @package PHPWord\Tests
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -68,4 +67,4 @@ class StylesTest extends \PHPUnit_Framework_TestCase
$element = $doc->getElement($path, $file); $element = $doc->getElement($path, $file);
$this->assertEquals('Normal', $element->getAttribute('w:val')); $this->assertEquals('Normal', $element->getAttribute('w:val'));
} }
} }

View File

@ -1,15 +1,13 @@
<?php <?php
namespace PHPWord\Tests\Writer; namespace PHPWord\Tests\Writer;
use PHPWord_Writer_Word2007; use PhpOffice\PhpWord\Writer\Word2007;
use PHPWord; use PHPWord;
use PHPWord\Tests\TestHelperDOCX; use PHPWord\Tests\TestHelperDOCX;
/** /**
* Class Word2007Test * @package PHPWord\Tests
* * @coversDefaultClass PhpOffice\PhpWord\Writer\Word2007
* @package PHPWord\Tests
* @coversDefaultClass PHPWord_Writer_Word2007
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class Word2007Test extends \PHPUnit_Framework_TestCase class Word2007Test extends \PHPUnit_Framework_TestCase
@ -20,29 +18,38 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
} }
/** /**
* covers ::__construct * covers ::__construct
*/ */
public function testConstruct() public function testConstruct()
{ {
$object = new PHPWord_Writer_Word2007(new PHPWord()); $object = new Word2007(new PHPWord());
$writerParts = array('ContentTypes', 'Rels', 'DocProps', $writerParts = array(
'DocumentRels', 'Document', 'Styles', 'Header', 'Footer', 'ContentTypes',
'Footnotes', 'FootnotesRels'); 'Rels',
'DocProps',
'DocumentRels',
'Document',
'Styles',
'Header',
'Footer',
'Footnotes',
'FootnotesRels',
);
foreach ($writerParts as $part) { foreach ($writerParts as $part) {
$this->assertInstanceOf( $this->assertInstanceOf(
"PHPWord_Writer_Word2007_{$part}", "PhpOffice\\PhpWord\\Writer\\Word2007\\{$part}",
$object->getWriterPart($part) $object->getWriterPart($part)
); );
$this->assertInstanceOf( $this->assertInstanceOf(
"PHPWord_Writer_Word2007", 'PhpOffice\\PhpWord\\Writer\\Word2007',
$object->getWriterPart($part)->getParentWriter() $object->getWriterPart($part)->getParentWriter()
); );
} }
} }
/** /**
* @covers ::save * @covers ::save
*/ */
public function testSave() public function testSave()
{ {
@ -57,7 +64,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
$textrun = $section->createTextRun(); $textrun = $section->createTextRun();
$textrun->addText('Test 3'); $textrun->addText('Test 3');
$writer = new PHPWord_Writer_Word2007($phpWord); $writer = new Word2007($phpWord);
$file = \join( $file = \join(
\DIRECTORY_SEPARATOR, \DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'temp.docx') array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'temp.docx')
@ -68,7 +75,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
} }
/** /**
* @covers ::checkContentTypes * @covers ::checkContentTypes
*/ */
public function testCheckContentTypes() public function testCheckContentTypes()
{ {
@ -98,20 +105,20 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
} }
/** /**
* @covers ::setUseDiskCaching * @covers ::setUseDiskCaching
* @covers ::getUseDiskCaching * @covers ::getUseDiskCaching
*/ */
public function testSetGetUseDiskCaching() public function testSetGetUseDiskCaching()
{ {
$object = new PHPWord_Writer_Word2007(); $object = new Word2007();
$object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT); $object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT);
$this->assertTrue($object->getUseDiskCaching()); $this->assertTrue($object->getUseDiskCaching());
} }
/** /**
* @covers ::setUseDiskCaching * @covers ::setUseDiskCaching
* @expectedException Exception * @expectedException Exception
*/ */
public function testSetUseDiskCachingException() public function testSetUseDiskCachingException()
{ {
@ -120,7 +127,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
array(\PHPWORD_TESTS_DIR_ROOT, 'foo') array(\PHPWORD_TESTS_DIR_ROOT, 'foo')
); );
$object = new PHPWord_Writer_Word2007(); $object = new Word2007();
$object->setUseDiskCaching(true, $dir); $object->setUseDiskCaching(true, $dir);
} }
} }

View File

@ -1,38 +1,33 @@
<?php <?php
namespace PHPWord\Tests; namespace PHPWord\Tests;
use PHPWord; use PhpOffice\PHPWord;
use PHPWord_DocumentProperties; use PhpOffice\PhpWord\DocumentProperties;
use PHPWord_Section; use PhpOffice\PhpWord\Section;
use PHPWord_Style; use PhpOffice\PhpWord\Style;
/** /**
* Class PHPWordTest * @package PHPWord\Tests
* * @coversDefaultClass PhpOffice\PHPWord
* @package PHPWord\Tests
* @covers PHPWord
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class PHPWordTest extends \PHPUnit_Framework_TestCase class PHPWordTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var PHPWord * @var PhpOffice\PHPWord
*/ */
protected $object; protected $object;
/** /**
* @covers PHPWord::__construct * @covers ::__construct
* @covers PHPWord::getProperties * @covers ::getProperties
* @covers PHPWord::getDefaultFontName * @covers ::getDefaultFontName
* @covers PHPWord::getDefaultFontSize * @covers ::getDefaultFontSize
*/ */
public function testConstruct() public function testConstruct()
{ {
$object = new PHPWord(); $object = new PHPWord();
$this->assertEquals( $this->assertEquals(new DocumentProperties(), $object->getProperties());
new PHPWord_DocumentProperties(),
$object->getProperties()
);
$this->assertEquals( $this->assertEquals(
PHPWord::DEFAULT_FONT_NAME, PHPWord::DEFAULT_FONT_NAME,
$object->getDefaultFontName() $object->getDefaultFontName()
@ -44,8 +39,8 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* @covers PHPWord::setProperties * @covers ::setProperties
* @covers PHPWord::getProperties * @covers ::getProperties
*/ */
public function testSetGetProperties() public function testSetGetProperties()
{ {
@ -58,20 +53,20 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* @covers PHPWord::createSection * @covers ::createSection
* @covers PHPWord::getSections * @covers ::getSections
*/ */
public function testCreateGetSections() public function testCreateGetSections()
{ {
$object = new PHPWord(); $object = new PHPWord();
$this->assertEquals(new PHPWord_Section(1), $object->createSection()); $this->assertEquals(new Section(1), $object->createSection());
$object->createSection(); $object->createSection();
$this->assertEquals(2, count($object->getSections())); $this->assertEquals(2, count($object->getSections()));
} }
/** /**
* @covers PHPWord::setDefaultFontName * @covers ::setDefaultFontName
* @covers PHPWord::getDefaultFontName * @covers ::getDefaultFontName
*/ */
public function testSetGetDefaultFontName() public function testSetGetDefaultFontName()
{ {
@ -86,8 +81,8 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* @covers PHPWord::setDefaultFontSize * @covers ::setDefaultFontSize
* @covers PHPWord::getDefaultFontSize * @covers ::getDefaultFontSize
*/ */
public function testSetGetDefaultFontSize() public function testSetGetDefaultFontSize()
{ {
@ -102,45 +97,42 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* @covers PHPWord::setDefaultParagraphStyle * @covers ::setDefaultParagraphStyle
* @covers PHPWord::loadTemplate * @covers ::loadTemplate
*/ */
public function testSetDefaultParagraphStyle() public function testSetDefaultParagraphStyle()
{ {
$object = new PHPWord(); $object = new PHPWord();
$object->setDefaultParagraphStyle(array()); $object->setDefaultParagraphStyle(array());
$this->assertInstanceOf( $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', Style::getStyle('Normal'));
'PHPWord_Style_Paragraph',
PHPWord_Style::getStyle('Normal')
);
} }
/** /**
* @covers PHPWord::addParagraphStyle * @covers ::addParagraphStyle
* @covers PHPWord::addFontStyle * @covers ::addFontStyle
* @covers PHPWord::addTableStyle * @covers ::addTableStyle
* @covers PHPWord::addLinkStyle * @covers ::addLinkStyle
*/ */
public function testAddStyles() public function testAddStyles()
{ {
$object = new PHPWord(); $object = new PHPWord();
$styles = array('Paragraph' => 'Paragraph', 'Font' => 'Font', $styles = array(
'Table' => 'TableFull', 'Link' => 'Font'); 'Paragraph' => 'Paragraph',
'Font' => 'Font',
'Table' => 'TableFull',
'Link' => 'Font',
);
foreach ($styles as $key => $value) { foreach ($styles as $key => $value) {
$method = "add{$key}Style"; $method = "add{$key}Style";
$styleId = "{$key} Style"; $styleId = "{$key} Style";
$styleType = "PHPWord_Style_{$value}";
$object->$method($styleId, array()); $object->$method($styleId, array());
$this->assertInstanceOf( $this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$value}", Style::getStyle($styleId));
$styleType,
PHPWord_Style::getStyle($styleId)
);
} }
} }
/** /**
* @covers PHPWord::addTitleStyle * @covers ::addTitleStyle
*/ */
public function testAddTitleStyle() public function testAddTitleStyle()
{ {
@ -148,14 +140,11 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
$titleLevel = 1; $titleLevel = 1;
$titleName = "Heading_{$titleLevel}"; $titleName = "Heading_{$titleLevel}";
$object->addTitleStyle($titleLevel, array()); $object->addTitleStyle($titleLevel, array());
$this->assertInstanceOf( $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', Style::getStyle($titleName));
'PHPWord_Style_Font',
PHPWord_Style::getStyle($titleName)
);
} }
/** /**
* @covers PHPWord::loadTemplate * @covers ::loadTemplate
*/ */
public function testLoadTemplate() public function testLoadTemplate()
{ {
@ -164,15 +153,12 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx') array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx')
); );
$object = new PHPWord(); $object = new PHPWord();
$this->assertInstanceOf( $this->assertInstanceOf('PhpOffice\\PhpWord\\Template', $object->loadTemplate($file));
'PHPWord_Template',
$object->loadTemplate($file)
);
} }
/** /**
* @covers PHPWord::loadTemplate * @covers ::loadTemplate
* @expectedException PHPWord_Exception * @expectedException PhpOffice\PhpWord\Exceptions\Exception
*/ */
public function testLoadTemplateException() public function testLoadTemplateException()
{ {
@ -183,4 +169,4 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
$object = new PHPWord(); $object = new PHPWord();
$object->loadTemplate($file); $object->loadTemplate($file);
} }
} }

View File

@ -2,6 +2,7 @@
namespace PHPWord\Tests; namespace PHPWord\Tests;
use PHPWord; use PHPWord;
use PhpOffice\PhpWord\IOFactory;
class TestHelperDOCX class TestHelperDOCX
{ {
@ -19,8 +20,8 @@ class TestHelperDOCX
mkdir(sys_get_temp_dir() . '/PHPWord_Unit_Test/'); mkdir(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
} }
$objWriter = \PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = IOFactory::createWriter($PHPWord, $writer);
$objWriter->save(self::$file); $xmlWriter->save(self::$file);
$zip = new \ZipArchive; $zip = new \ZipArchive;
$res = $zip->open(self::$file); $res = $zip->open(self::$file);

View File

@ -52,11 +52,11 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }
// Done // Done
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;

View File

@ -11,19 +11,19 @@ $PHPWord = new PHPWord();
// Ads styles // Ads styles
$PHPWord->addParagraphStyle('multipleTab', array( $PHPWord->addParagraphStyle('multipleTab', array(
'tabs' => array( 'tabs' => array(
new PHPWord_Style_Tab('left', 1550), new PhpOffice\PhpWord\Style\Tab('left', 1550),
new PHPWord_Style_Tab('center', 3200), new PhpOffice\PhpWord\Style\Tab('center', 3200),
new PHPWord_Style_Tab('right', 5300) new PhpOffice\PhpWord\Style\Tab('right', 5300)
) )
)); ));
$PHPWord->addParagraphStyle('rightTab', array( $PHPWord->addParagraphStyle('rightTab', array(
'tabs' => array( 'tabs' => array(
new PHPWord_Style_Tab('right', 9090) new PhpOffice\PhpWord\Style\Tab('right', 9090)
) )
)); ));
$PHPWord->addParagraphStyle('centerTab', array( $PHPWord->addParagraphStyle('centerTab', array(
'tabs' => array( 'tabs' => array(
new PHPWord_Style_Tab('center', 4680) new PhpOffice\PhpWord\Style\Tab('center', 4680)
) )
)); ));
@ -40,8 +40,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -33,8 +33,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -8,12 +8,11 @@ require_once '../Classes/PHPWord.php';
echo date('H:i:s') , ' Create new PHPWord object' , EOL; echo date('H:i:s') , ' Create new PHPWord object' , EOL;
$PHPWord = new PHPWord(); $PHPWord = new PHPWord();
// Ads styles // Ads styles
$PHPWord->addParagraphStyle('pStyle', array('spacing'=>100)); $PHPWord->addParagraphStyle('pStyle', array('spacing'=>100));
$PHPWord->addFontStyle('BoldText', array('bold'=>true)); $PHPWord->addFontStyle('BoldText', array('bold'=>true));
$PHPWord->addFontStyle('ColoredText', array('color'=>'FF8080')); $PHPWord->addFontStyle('ColoredText', array('color'=>'FF8080'));
$PHPWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline'=>PHPWord_Style_Font::UNDERLINE_SINGLE)); $PHPWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
// New portrait section // New portrait section
$section = $PHPWord->createSection(); $section = $PHPWord->createSection();
@ -40,8 +39,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -43,8 +43,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -15,7 +15,7 @@ $section = $PHPWord->createSection();
$PHPWord->addParagraphStyle('pStyle', array('spacing'=>100)); $PHPWord->addParagraphStyle('pStyle', array('spacing'=>100));
$PHPWord->addFontStyle('BoldText', array('bold'=>true)); $PHPWord->addFontStyle('BoldText', array('bold'=>true));
$PHPWord->addFontStyle('ColoredText', array('color'=>'FF8080')); $PHPWord->addFontStyle('ColoredText', array('color'=>'FF8080'));
$PHPWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline'=>PHPWord_Style_Font::UNDERLINE_SINGLE)); $PHPWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
// Add text elements // Add text elements
$textrun = $section->createTextRun('pStyle'); $textrun = $section->createTextRun('pStyle');
@ -41,8 +41,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -9,7 +9,7 @@ echo date('H:i:s') , " Create new PHPWord object" , EOL;
$PHPWord = new PHPWord(); $PHPWord = new PHPWord();
$PHPWord->setDefaultParagraphStyle(array( $PHPWord->setDefaultParagraphStyle(array(
'align' => 'both', 'align' => 'both',
'spaceAfter' => PHPWord_Shared_Font::pointSizeToTwips(12), 'spaceAfter' => PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(12),
'spacing' => 120, 'spacing' => 120,
)); ));
@ -53,8 +53,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -32,7 +32,7 @@ $section->addText("Fancy table", $header);
$styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80); $styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80);
$styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF'); $styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF');
$styleCell = array('valign' => 'center'); $styleCell = array('valign' => 'center');
$styleCellBTLR = array('valign' => 'center', 'textDirection' => PHPWord_Style_Cell::TEXT_DIR_BTLR); $styleCellBTLR = array('valign' => 'center', 'textDirection' => PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR);
$fontStyle = array('bold' => true, 'align' => 'center'); $fontStyle = array('bold' => true, 'align' => 'center');
$PHPWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow); $PHPWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow);
$table = $section->addTable('Fancy Table'); $table = $section->addTable('Fancy Table');
@ -81,8 +81,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -17,8 +17,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -8,14 +8,14 @@ require_once '../Classes/PHPWord.php';
$name = basename(__FILE__, '.php'); $name = basename(__FILE__, '.php');
$source = "resources/{$name}.docx"; $source = "resources/{$name}.docx";
echo date('H:i:s'), " Reading contents from `{$source}`", EOL; echo date('H:i:s'), " Reading contents from `{$source}`", EOL;
$PHPWord = PHPWord_IOFactory::load($source); $PHPWord = PhpOffice\PhpWord\IOFactory::load($source);
// (Re)write contents // (Re)write contents
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -64,8 +64,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -32,8 +32,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -31,7 +31,7 @@ $section->addListItem('List Item 1.3.2', 2);
$section->addTextBreak(2); $section->addTextBreak(2);
// Add listitem elements // Add listitem elements
$listStyle = array('listType'=>PHPWord_Style_ListItem::TYPE_NUMBER); $listStyle = array('listType' => PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER);
$section->addListItem('List Item 1', 0, null, $listStyle); $section->addListItem('List Item 1', 0, null, $listStyle);
$section->addListItem('List Item 2', 0, null, $listStyle); $section->addListItem('List Item 2', 0, null, $listStyle);
$section->addListItem('List Item 3', 0, null, $listStyle); $section->addListItem('List Item 3', 0, null, $listStyle);
@ -40,7 +40,7 @@ $section->addTextBreak(2);
// Add listitem elements // Add listitem elements
$PHPWord->addFontStyle('myOwnStyle', array('color'=>'FF0000')); $PHPWord->addFontStyle('myOwnStyle', array('color'=>'FF0000'));
$PHPWord->addParagraphStyle('P-Style', array('spaceAfter'=>95)); $PHPWord->addParagraphStyle('P-Style', array('spaceAfter'=>95));
$listStyle = array('listType'=>PHPWord_Style_ListItem::TYPE_NUMBER_NESTED); $listStyle = array('listType' => PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER_NESTED);
$section->addListItem('List Item 1', 0, 'myOwnStyle', $listStyle, 'P-Style'); $section->addListItem('List Item 1', 0, 'myOwnStyle', $listStyle, 'P-Style');
$section->addListItem('List Item 2', 0, 'myOwnStyle', $listStyle, 'P-Style'); $section->addListItem('List Item 2', 0, 'myOwnStyle', $listStyle, 'P-Style');
$section->addListItem('List Item 3', 1, 'myOwnStyle', $listStyle, 'P-Style'); $section->addListItem('List Item 3', 1, 'myOwnStyle', $listStyle, 'P-Style');
@ -56,8 +56,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -16,7 +16,7 @@ $PHPWord = new PHPWord();
$section = $PHPWord->createSection(); $section = $PHPWord->createSection();
// Add hyperlink elements // Add hyperlink elements
$section->addLink('http://www.google.com', 'Best search engine', array('color'=>'0000FF', 'underline'=>PHPWord_Style_Font::UNDERLINE_SINGLE)); $section->addLink('http://www.google.com', 'Best search engine', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
$section->addTextBreak(2); $section->addTextBreak(2);
$PHPWord->addLinkStyle('myOwnLinkStyle', array('bold'=>true, 'color'=>'808000')); $PHPWord->addLinkStyle('myOwnLinkStyle', array('bold'=>true, 'color'=>'808000'));
@ -30,8 +30,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -25,8 +25,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -57,8 +57,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -26,8 +26,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }

View File

@ -39,8 +39,8 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) { foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL; echo date('H:i:s'), " Write to {$writer} format", EOL;
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
$objWriter->save("{$name}.{$extension}"); $xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}");
} }