From 4e546d1a21a1c56d724ed7a67a8fe366428dad89 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 19 Mar 2014 11:04:48 +0400 Subject: [PATCH] https://github.com/PHPOffice/PHPWord/issues/58 - Part IV. --- Classes/PHPWord/Reader/AbstractReader.php | 12 +-- Tests/PHPWord/SectionTest.php | 3 +- Tests/PHPWord/Shared/DrawingTest.php | 24 +++-- Tests/PHPWord/Shared/FileTest.php | 34 ++----- Tests/PHPWord/Shared/FontTest.php | 20 ++-- Tests/PHPWord/Shared/StringTest.php | 24 +++-- Tests/PHPWord/Style/CellTest.php | 14 ++- Tests/PHPWord/Style/FontTest.php | 18 ++-- Tests/PHPWord/Style/ImageTest.php | 12 +-- Tests/PHPWord/Style/ListItemTest.php | 18 ++-- Tests/PHPWord/Style/ParagraphTest.php | 23 ++--- Tests/PHPWord/Style/RowTest.php | 8 +- Tests/PHPWord/Style/TOCTest.php | 14 ++- Tests/PHPWord/Style/TableFullTest.php | 18 ++-- Tests/PHPWord/Style/TableTest.php | 10 +- Tests/PHPWord/Style/TabsTest.php | 13 +-- Tests/PHPWord/StyleTest.php | 37 ++++--- Tests/PHPWord/TOCTest.php | 37 ++++--- Tests/PHPWord/TemplateTest.php | 10 +- Tests/PHPWord/Writer/ODText/ContentTest.php | 13 +-- Tests/PHPWord/Writer/ODTextTest.php | 65 ++++++------ Tests/PHPWord/Writer/RTFTest.php | 46 +++++---- Tests/PHPWord/Writer/Word2007/BaseTest.php | 36 ++++--- .../PHPWord/Writer/Word2007/DocumentTest.php | 15 ++- .../PHPWord/Writer/Word2007/FootnotesTest.php | 3 +- Tests/PHPWord/Writer/Word2007/StylesTest.php | 3 +- Tests/PHPWord/Writer/Word2007Test.php | 51 +++++----- Tests/PHPWordTest.php | 98 ++++++++----------- Tests/_inc/TestHelperDOCX.php | 5 +- samples/Sample_01_SimpleText.php | 6 +- samples/Sample_02_TabStops.php | 14 +-- samples/Sample_03_Sections.php | 4 +- samples/Sample_04_Textrun.php | 7 +- samples/Sample_05_Multicolumn.php | 4 +- samples/Sample_06_Footnote.php | 6 +- samples/Sample_08_ParagraphPagination.php | 6 +- samples/Sample_09_Tables.php | 6 +- samples/Sample_10_EastAsianFontStyle.php | 4 +- samples/Sample_11_ReadWord2007.php | 6 +- samples/Sample_12_HeaderFooter.php | 4 +- samples/Sample_13_Images.php | 4 +- samples/Sample_14_ListItem.php | 8 +- samples/Sample_15_Link.php | 6 +- samples/Sample_16_Object.php | 4 +- samples/Sample_17_TitleTOC.php | 4 +- samples/Sample_18_Watermark.php | 4 +- samples/Sample_19_TextBreak.php | 4 +- 47 files changed, 354 insertions(+), 431 deletions(-) diff --git a/Classes/PHPWord/Reader/AbstractReader.php b/Classes/PHPWord/Reader/AbstractReader.php index ba7f6565..4932d054 100644 --- a/Classes/PHPWord/Reader/AbstractReader.php +++ b/Classes/PHPWord/Reader/AbstractReader.php @@ -25,14 +25,14 @@ * @version 0.8.0 */ +namespace PhpOffice\PhpWord\Reader; + 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? @@ -61,7 +61,7 @@ abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader * Set read data only * * @param bool $pValue - * @return PHPWord_Reader_IReader + * @return PhpOffice\PhpWord\Reader\IReader */ 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 * @return bool diff --git a/Tests/PHPWord/SectionTest.php b/Tests/PHPWord/SectionTest.php index 559a345e..19a61c1c 100644 --- a/Tests/PHPWord/SectionTest.php +++ b/Tests/PHPWord/SectionTest.php @@ -107,8 +107,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase // 'Title', 'TextRun'); // $i = 0; // foreach ($elementTypes as $elementType) { - // $objectType = "PHPWord_Section_{$elementType}"; - // $this->assertInstanceOf($objectType, $elementCollection[$i]); + // $this->assertInstanceOf("PhpOffice\\PhpWord\\Section\\{$elementType}", $elementCollection[$i]); // $i++; // } } diff --git a/Tests/PHPWord/Shared/DrawingTest.php b/Tests/PHPWord/Shared/DrawingTest.php index 550ee67c..a49773d8 100644 --- a/Tests/PHPWord/Shared/DrawingTest.php +++ b/Tests/PHPWord/Shared/DrawingTest.php @@ -1,11 +1,9 @@ assertEquals(round($value * 9525), $result); - $result = PHPWord_Shared_Drawing::EMUToPixels($value); + $result = Drawing::EMUToPixels($value); $this->assertEquals(round($value / 9525), $result); - $result = PHPWord_Shared_Drawing::pixelsToPoints($value); + $result = Drawing::pixelsToPoints($value); $this->assertEquals($value * 0.67777777, $result); - $result = PHPWord_Shared_Drawing::pointsToPixels($value); + $result = Drawing::pointsToPixels($value); $this->assertEquals($value * 1.333333333, $result); - $result = PHPWord_Shared_Drawing::degreesToAngle($value); + $result = Drawing::degreesToAngle($value); $this->assertEquals((int)round($value * 60000), $result); - $result = PHPWord_Shared_Drawing::angleToDegrees($value); + $result = Drawing::angleToDegrees($value); $this->assertEquals(round($value / 60000), $result); - $result = PHPWord_Shared_Drawing::pixelsToCentimeters($value); + $result = Drawing::pixelsToCentimeters($value); $this->assertEquals($value * 0.028, $result); - $result = PHPWord_Shared_Drawing::centimetersToPixels($value); + $result = Drawing::centimetersToPixels($value); $this->assertEquals($value / 0.028, $result); } } @@ -59,8 +57,8 @@ class DrawingTest extends \PHPUnit_Framework_TestCase $values[] = array('0F9D', false); // 4 characters // Conduct test foreach ($values as $value) { - $result = PHPWord_Shared_Drawing::htmlToRGB($value[0]); + $result = Drawing::htmlToRGB($value[0]); $this->assertEquals($value[1], $result); } } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Shared/FileTest.php b/Tests/PHPWord/Shared/FileTest.php index a5ac348f..6a62b100 100644 --- a/Tests/PHPWord/Shared/FileTest.php +++ b/Tests/PHPWord/Shared/FileTest.php @@ -1,13 +1,11 @@ assertTrue(PHPWord_Shared_File::file_exists('blank.docx')); + $this->assertTrue(File::file_exists('blank.docx')); } /** * Test file_exists() */ public function testNoFileExists() { - $dir = join(DIRECTORY_SEPARATOR, array( - PHPWORD_TESTS_DIR_ROOT, - '_files', - 'templates' - )); + $dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates')); 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() { - $dir = join(DIRECTORY_SEPARATOR, array( - PHPWORD_TESTS_DIR_ROOT, - '_files', - 'templates' - )); + $dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates')); chdir($dir); $file = 'blank.docx'; $expected = $dir . DIRECTORY_SEPARATOR . $file; - $this->assertEquals($expected, PHPWord_Shared_File::realpath($file)); + $this->assertEquals($expected, File::realpath($file)); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Shared/FontTest.php b/Tests/PHPWord/Shared/FontTest.php index 5a40e465..e87bda45 100644 --- a/Tests/PHPWord/Shared/FontTest.php +++ b/Tests/PHPWord/Shared/FontTest.php @@ -2,11 +2,9 @@ namespace PHPWord\Tests\Shared; use PHPWord; -use PHPWord_Shared_Font; +use PhpOffice\PhpWord\Shared\Font; /** - * Class FontTest - * * @package PHPWord\Tests * @runTestsInSeparateProcesses */ @@ -21,25 +19,25 @@ class FontTest extends \PHPUnit_Framework_TestCase $original = 1; - $result = PHPWord_Shared_Font::fontSizeToPixels($original); + $result = Font::fontSizeToPixels($original); $this->assertEquals($original * 16 / 12, $result); - $result = PHPWord_Shared_Font::inchSizeToPixels($original); + $result = Font::inchSizeToPixels($original); $this->assertEquals($original * 96, $result); - $result = PHPWord_Shared_Font::centimeterSizeToPixels($original); + $result = Font::centimeterSizeToPixels($original); $this->assertEquals($original * 37.795275591, $result); - $result = PHPWord_Shared_Font::centimeterSizeToTwips($original); + $result = Font::centimeterSizeToTwips($original); $this->assertEquals($original * 565.217, $result); - $result = PHPWord_Shared_Font::inchSizeToTwips($original); + $result = Font::inchSizeToTwips($original); $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); - $result = PHPWord_Shared_Font::pointSizeToTwips($original); + $result = Font::pointSizeToTwips($original); $this->assertEquals($original * 20, $result); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Shared/StringTest.php b/Tests/PHPWord/Shared/StringTest.php index 3698e2e0..d8918f55 100644 --- a/Tests/PHPWord/Shared/StringTest.php +++ b/Tests/PHPWord/Shared/StringTest.php @@ -1,33 +1,31 @@ assertTrue(PHPWord_Shared_String::IsUTF8('')); - $this->assertTrue(PHPWord_Shared_String::IsUTF8('éééé')); - $this->assertFalse(PHPWord_Shared_String::IsUTF8(utf8_decode('éééé'))); + $this->assertTrue(String::IsUTF8('')); + $this->assertTrue(String::IsUTF8('éééé')); + $this->assertFalse(String::IsUTF8(utf8_decode('éééé'))); } public function testControlCharacterOOXML2PHP() { - $this->assertEquals('', PHPWord_Shared_String::ControlCharacterOOXML2PHP('')); - $this->assertEquals(chr(0x08), PHPWord_Shared_String::ControlCharacterOOXML2PHP('_x0008_')); + $this->assertEquals('', String::ControlCharacterOOXML2PHP('')); + $this->assertEquals(chr(0x08), String::ControlCharacterOOXML2PHP('_x0008_')); } public function testControlCharacterPHP2OOXML() { - $this->assertEquals('', PHPWord_Shared_String::ControlCharacterPHP2OOXML('')); - $this->assertEquals('_x0008_', PHPWord_Shared_String::ControlCharacterPHP2OOXML(chr(0x08))); + $this->assertEquals('', String::ControlCharacterPHP2OOXML('')); + $this->assertEquals('_x0008_', String::ControlCharacterPHP2OOXML(chr(0x08))); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/CellTest.php b/Tests/PHPWord/Style/CellTest.php index 0d470951..8bf5c6a3 100644 --- a/Tests/PHPWord/Style/CellTest.php +++ b/Tests/PHPWord/Style/CellTest.php @@ -1,11 +1,9 @@ 'left', - 'textDirection' => PHPWord_Style_Cell::TEXT_DIR_BTLR, + 'textDirection' => Cell::TEXT_DIR_BTLR, 'bgColor' => 'FFFF00', 'borderTopSize' => 120, 'borderTopColor' => 'FFFF00', @@ -46,7 +44,7 @@ class CellTest extends \PHPUnit_Framework_TestCase */ public function testBorderColor() { - $object = new PHPWord_Style_Cell(); + $object = new Cell(); $default = '000000'; $value = 'FF0000'; @@ -66,11 +64,11 @@ class CellTest extends \PHPUnit_Framework_TestCase */ public function testBorderSize() { - $object = new PHPWord_Style_Cell(); + $object = new Cell(); $value = 120; $expected = array($value, $value, $value, $value); $object->setStyleValue('_borderSize', $value); $this->assertEquals($expected, $object->getBorderSize()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/FontTest.php b/Tests/PHPWord/Style/FontTest.php index 46cec029..7f317933 100644 --- a/Tests/PHPWord/Style/FontTest.php +++ b/Tests/PHPWord/Style/FontTest.php @@ -2,12 +2,10 @@ namespace PHPWord\Tests\Style; use PHPWord; -use PHPWord_Style_Font; +use PhpOffice\PhpWord\Style\Font; use PHPWord\Tests\TestHelperDOCX; /** - * Class FontTest - * * @package PHPWord\Tests * @runTestsInSeparateProcesses */ @@ -23,10 +21,10 @@ class FontTest extends \PHPUnit_Framework_TestCase */ 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->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() { - $object = new PHPWord_Style_Font(); + $object = new Font(); $attributes = array( 'name' => PHPWord::DEFAULT_FONT_NAME, @@ -43,7 +41,7 @@ class FontTest extends \PHPUnit_Framework_TestCase 'italic' => false, 'superScript' => false, 'subScript' => false, - 'underline' => PHPWord_Style_Font::UNDERLINE_NONE, + 'underline' => Font::UNDERLINE_NONE, 'strikethrough' => false, 'color' => PHPWord::DEFAULT_FONT_COLOR, 'fgColor' => null, @@ -62,7 +60,7 @@ class FontTest extends \PHPUnit_Framework_TestCase */ public function testSetStyleValueNormal() { - $object = new PHPWord_Style_Font(); + $object = new Font(); $attributes = array( 'name' => 'Times New Roman', @@ -71,7 +69,7 @@ class FontTest extends \PHPUnit_Framework_TestCase 'italic' => true, 'superScript' => true, 'subScript' => true, - 'underline' => PHPWord_Style_Font::UNDERLINE_HEAVY, + 'underline' => Font::UNDERLINE_HEAVY, 'strikethrough' => true, 'color' => '999999', 'fgColor' => '999999', @@ -113,4 +111,4 @@ class FontTest extends \PHPUnit_Framework_TestCase $this->assertEquals(720, $lineHeight); $this->assertEquals('auto', $lineRule); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/ImageTest.php b/Tests/PHPWord/Style/ImageTest.php index 7e7b3888..2ed15f4f 100644 --- a/Tests/PHPWord/Style/ImageTest.php +++ b/Tests/PHPWord/Style/ImageTest.php @@ -1,11 +1,9 @@ 200, @@ -39,7 +37,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase */ public function testSetStyleValue() { - $object = new PHPWord_Style_Image(); + $object = new Image(); $properties = array( 'width' => 200, @@ -62,7 +60,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase */ public function testSetWrappingStyleException() { - $object = new PHPWord_Style_Image(); + $object = new Image(); $object->setWrappingStyle('foo'); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/ListItemTest.php b/Tests/PHPWord/Style/ListItemTest.php index 890f4683..afc9744d 100644 --- a/Tests/PHPWord/Style/ListItemTest.php +++ b/Tests/PHPWord/Style/ListItemTest.php @@ -1,11 +1,9 @@ assertEquals($value, $object->getListType()); } @@ -27,9 +25,9 @@ class ListItemTest extends \PHPUnit_Framework_TestCase */ 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); $this->assertEquals($value, $object->getListType()); } @@ -39,10 +37,10 @@ class ListItemTest extends \PHPUnit_Framework_TestCase */ public function testListType() { - $object = new PHPWord_Style_ListItem(); + $object = new ListItem(); - $value = PHPWord_Style_ListItem::TYPE_ALPHANUM; + $value = ListItem::TYPE_ALPHANUM; $object->setListType($value); $this->assertEquals($value, $object->getListType()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/ParagraphTest.php b/Tests/PHPWord/Style/ParagraphTest.php index ff084a57..d005078c 100644 --- a/Tests/PHPWord/Style/ParagraphTest.php +++ b/Tests/PHPWord/Style/ParagraphTest.php @@ -2,13 +2,11 @@ namespace PHPWord\Tests\Style; use PHPWord; -use PHPWord_Style_Paragraph; -use PHPWord_Style_Tab; +use PhpOffice\PhpWord\Style\Paragraph; +use PhpOffice\PhpWord\Style\Tab; use PHPWord\Tests\TestHelperDOCX; /** - * Class ParagraphTest - * * @package PHPWord\Tests * @runTestsInSeparateProcesses */ @@ -24,7 +22,7 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase */ public function testSetStyleValueWithNullOrEmpty() { - $object = new PHPWord_Style_Paragraph(); + $object = new Paragraph(); $attributes = array( 'tabs' => null, @@ -47,7 +45,7 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase */ public function testSetStyleValueNormal() { - $object = new PHPWord_Style_Paragraph(); + $object = new Paragraph(); $attributes = array( 'align' => 'justify', @@ -84,12 +82,9 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase */ public function testTabs() { - $object = new PHPWord_Style_Paragraph(); - $object->setTabs(array( - new PHPWord_Style_Tab('left', 1550), - new PHPWord_Style_Tab('right', 5300), - )); - $this->assertInstanceOf('PHPWord_Style_Tabs', $object->getTabs()); + $object = new Paragraph(); + $object->setTabs(array(new Tab('left', 1550), new Tab('right', 5300))); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Tabs', $object->getTabs()); } public function testLineHeight() @@ -128,8 +123,8 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase */ public function testLineHeightValidation() { - $object = new PHPWord_Style_Paragraph(); + $object = new Paragraph(); $object->setLineHeight('12.5pt'); $this->assertEquals(12.5, $object->getLineHeight()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/RowTest.php b/Tests/PHPWord/Style/RowTest.php index cbbecfbc..97131509 100644 --- a/Tests/PHPWord/Style/RowTest.php +++ b/Tests/PHPWord/Style/RowTest.php @@ -1,11 +1,9 @@ true, @@ -37,4 +35,4 @@ class RowTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $object->$get()); } } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/TOCTest.php b/Tests/PHPWord/Style/TOCTest.php index 4607ba37..3e34a82c 100644 --- a/Tests/PHPWord/Style/TOCTest.php +++ b/Tests/PHPWord/Style/TOCTest.php @@ -1,13 +1,11 @@ 9062, - 'tabLeader' => PHPWord_Style_TOC::TABLEADER_DOT, + 'tabLeader' => TOC::TABLEADER_DOT, 'indent' => 200, ); foreach ($properties as $key => $value) { @@ -36,4 +34,4 @@ class TOCTest extends \PHPUnit_Framework_TestCase $this->assertEquals(null, $object->$get()); } } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/TableFullTest.php b/Tests/PHPWord/Style/TableFullTest.php index 7f7b7732..6edc74c9 100644 --- a/Tests/PHPWord/Style/TableFullTest.php +++ b/Tests/PHPWord/Style/TableFullTest.php @@ -1,11 +1,9 @@ 'FF0000'); $styleFirstRow = array('borderBottomSize' => 3); - $object = new PHPWord_Style_TableFull($styleTable, $styleFirstRow); + $object = new TableFull($styleTable, $styleFirstRow); $this->assertEquals('FF0000', $object->getBgColor()); $firstRow = $object->getFirstRow(); - $this->assertInstanceOf('PHPWord_Style_TableFull', $firstRow); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\TableFull', $firstRow); $this->assertEquals(3, $firstRow->getBorderBottomSize()); } @@ -37,7 +35,7 @@ class TableFullTest extends \PHPUnit_Framework_TestCase */ public function testSetGetNormal() { - $object = new PHPWord_Style_TableFull(); + $object = new TableFull(); $attributes = array( 'bgColor' => 'FF0000', @@ -74,7 +72,7 @@ class TableFullTest extends \PHPUnit_Framework_TestCase */ public function testBorderColor() { - $object = new PHPWord_Style_TableFull(); + $object = new TableFull(); $parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV'); $value = 'FF0000'; @@ -96,7 +94,7 @@ class TableFullTest extends \PHPUnit_Framework_TestCase */ public function testBorderSize() { - $object = new PHPWord_Style_TableFull(); + $object = new TableFull(); $parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV'); $value = 4; @@ -118,7 +116,7 @@ class TableFullTest extends \PHPUnit_Framework_TestCase */ public function testCellMargin() { - $object = new PHPWord_Style_TableFull(); + $object = new TableFull(); $parts = array('Top', 'Left', 'Right', 'Bottom'); $value = 240; @@ -130,4 +128,4 @@ class TableFullTest extends \PHPUnit_Framework_TestCase } $this->assertEquals($values, $object->getCellMargin()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/TableTest.php b/Tests/PHPWord/Style/TableTest.php index 439aa5ae..1a2da789 100644 --- a/Tests/PHPWord/Style/TableTest.php +++ b/Tests/PHPWord/Style/TableTest.php @@ -1,11 +1,9 @@ assertEquals($values, $object->getCellMargin()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/TabsTest.php b/Tests/PHPWord/Style/TabsTest.php index 7579ae6d..d6aa4342 100644 --- a/Tests/PHPWord/Style/TabsTest.php +++ b/Tests/PHPWord/Style/TabsTest.php @@ -2,13 +2,10 @@ namespace PHPWord\Tests\Style; use PHPWord; -use PHPWord_Style_Tab; -use PHPWord_Style_Tabs; +use PhpOffice\PhpWord\Style\Tab; use PHPWord\Tests\TestHelperDOCX; /** - * Class TabsTest - * * @package PHPWord\Tests * @runTestsInSeparateProcesses */ @@ -28,11 +25,7 @@ class TabsTest extends \PHPUnit_Framework_TestCase public function testTabsStyle() { $PHPWord = new PHPWord(); - $PHPWord->addParagraphStyle('tabbed', array( - 'tabs' => array( - new PHPWord_Style_Tab('left', 1440, 'dot'), - ) - )); + $PHPWord->addParagraphStyle('tabbed', array('tabs' => array(new Tab('left', 1440, 'dot')))); $doc = TestHelperDOCX::getDocument($PHPWord); $file = 'word/styles.xml'; $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('dot', $element->getAttribute('w:leader')); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/StyleTest.php b/Tests/PHPWord/StyleTest.php index 9e442cb1..bdca8ea7 100644 --- a/Tests/PHPWord/StyleTest.php +++ b/Tests/PHPWord/StyleTest.php @@ -1,22 +1,20 @@ 'Font', 'Table' => 'TableFull', 'Heading_1' => 'Font', 'Normal' => 'Paragraph'); $elementCount = 6; - PHPWord_Style::addParagraphStyle('Paragraph', $paragraph); - PHPWord_Style::addFontStyle('Font', $font); - PHPWord_Style::addLinkStyle('Link', $font); - PHPWord_Style::addTableStyle('Table', $table); - PHPWord_Style::addTitleStyle(1, $font); - PHPWord_Style::setDefaultParagraphStyle($paragraph); + Style::addParagraphStyle('Paragraph', $paragraph); + Style::addFontStyle('Font', $font); + Style::addLinkStyle('Link', $font); + Style::addTableStyle('Table', $table); + Style::addTitleStyle(1, $font); + Style::setDefaultParagraphStyle($paragraph); - $this->assertEquals($elementCount, count(PHPWord_Style::getStyles())); + $this->assertEquals($elementCount, count(Style::getStyles())); foreach ($styles as $name => $style) { - $expected = "PHPWord_Style_{$style}"; - $this->assertInstanceOf($expected, PHPWord_Style::getStyle($name)); + $this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$style}", Style::getStyle($name)); } - $this->assertNull(PHPWord_Style::getStyle('Unknown')); + $this->assertNull(Style::getStyle('Unknown')); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/TOCTest.php b/Tests/PHPWord/TOCTest.php index d4503da5..9048d009 100644 --- a/Tests/PHPWord/TOCTest.php +++ b/Tests/PHPWord/TOCTest.php @@ -1,38 +1,35 @@ 9062, - 'tabLeader' => PHPWord_Style_TOC::TABLEADER_DOT, + 'tabLeader' => PhpOffice\PhpWord\Style\TOC::TABLEADER_DOT, 'indent' => 200, ); - $object = new PHPWord_TOC( + $object = new TOC( array('size' => 11), array('tabPos' => $expected['tabPos']) ); $tocStyle = $object->getStyleTOC(); - $this->assertInstanceOf('PHPWord_Style_TOC', $tocStyle); - $this->assertInstanceOf('PHPWord_Style_Font', $object->getStyleFont()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\TOC', $tocStyle); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $object->getStyleFont()); foreach ($expected as $key => $value) { $method = "get{$key}"; @@ -41,8 +38,8 @@ class TOCTest extends \PHPUnit_Framework_TestCase } /** - * @covers PHPWord_TOC::addTitle - * @covers PHPWord_TOC::getTitles + * @covers ::addTitle + * @covers ::getTitles */ public function testAddAndGetTitle() { @@ -56,20 +53,20 @@ class TOCTest extends \PHPUnit_Framework_TestCase 'Heading 3' => 3, ); - // @covers PHPWord_TOC::addTitle + // @covers ::addTitle foreach ($titles as $text => $depth) { - $response = PHPWord_TOC::addTitle($text, $depth); + $response = TOC::addTitle($text, $depth); } $this->assertEquals($anchor, $response[0]); $this->assertEquals($bookmark, $response[1]); - // @covers PHPWord_TOC::getTitles + // @covers ::getTitles $i = 0; - $savedTitles = PHPWord_TOC::getTitles(); + $savedTitles = TOC::getTitles(); foreach ($titles as $text => $depth) { $this->assertEquals($text, $savedTitles[$i]['text']); $this->assertEquals($depth, $savedTitles[$i]['depth']); $i++; } } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/TemplateTest.php b/Tests/PHPWord/TemplateTest.php index 872ab182..7c7417d5 100644 --- a/Tests/PHPWord/TemplateTest.php +++ b/Tests/PHPWord/TemplateTest.php @@ -1,11 +1,11 @@ load( \join( @@ -93,7 +93,7 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase */ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue() { - $template = new PHPWord_Template( + $template = new Template( \join( \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx') @@ -123,7 +123,7 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase */ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplate() { - $template = new PHPWord_Template( + $template = new Template( \join( \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'corrupted_main_document_part.docx') diff --git a/Tests/PHPWord/Writer/ODText/ContentTest.php b/Tests/PHPWord/Writer/ODText/ContentTest.php index 63b84d75..31659d32 100644 --- a/Tests/PHPWord/Writer/ODText/ContentTest.php +++ b/Tests/PHPWord/Writer/ODText/ContentTest.php @@ -2,14 +2,11 @@ namespace PHPWord\Tests\Writer\ODText; use PHPWord; -use PHPWord_Style; use PHPWord\Tests\TestHelperDOCX; /** - * Class ContentTest - * - * @package PHPWord\Tests - * @coversDefaultClass PHPWord_Writer_ODText_Content + * @package PHPWord\Tests + * @coversDefaultClass PhpOffice\PhpWord\Writer\ODText\Content * @runTestsInSeparateProcesses */ class ContentTest extends \PHPUnit_Framework_TestCase @@ -23,8 +20,8 @@ class ContentTest extends \PHPUnit_Framework_TestCase } /** - * covers ::writeContent - * covers + * covers ::writeContent + * covers */ public function testWriteContent() { @@ -62,4 +59,4 @@ class ContentTest extends \PHPUnit_Framework_TestCase $element = "/office:document-content/office:body/office:text/text:p"; $this->assertEquals($expected, $doc->getElement($element, 'content.xml')->nodeValue); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/ODTextTest.php b/Tests/PHPWord/Writer/ODTextTest.php index ef92d249..f1cc7213 100644 --- a/Tests/PHPWord/Writer/ODTextTest.php +++ b/Tests/PHPWord/Writer/ODTextTest.php @@ -1,14 +1,12 @@ assertInstanceOf('PHPWord', $object->getPHPWord()); - $this->assertInstanceOf("PHPWord_HashTable", $object->getDrawingHashTable()); + $this->assertInstanceOf('PhpOffice\\PHPWord', $object->getPHPWord()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\HashTable', $object->getDrawingHashTable()); $this->assertEquals('./', $object->getDiskCachingDirectory()); - $writerParts = array('Content', 'Manifest', 'Meta', 'Mimetype', 'Styles'); - foreach ($writerParts as $part) { + foreach (array('Content', 'Manifest', 'Meta', 'Mimetype', 'Styles') as $part) { $this->assertInstanceOf( - "PHPWord_Writer_ODText_{$part}", + "PhpOffice\\PhpWord\\Writer\\ODText\\{$part}", $object->getWriterPart($part) ); $this->assertInstanceOf( - "PHPWord_Writer_ODText", + 'PhpOffice\\PhpWord\\Writer\\ODText', $object->getWriterPart($part)->getParentWriter() ); } } /** - * @covers ::getPHPWord - * @expectedException Exception - * @expectedExceptionMessage No PHPWord assigned. + * @covers ::getPHPWord + * @expectedException Exception + * @expectedExceptionMessage No PHPWord assigned. */ public function testConstructWithNull() { - $object = new PHPWord_Writer_ODText(); + $object = new ODText(); $object->getPHPWord(); } /** - * @covers ::save + * @covers ::save */ public function testSave() { @@ -84,7 +81,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase $section = $phpWord->createSection(); $textrun = $section->createTextRun(); $textrun->addText('Test 3'); - $writer = new PHPWord_Writer_ODText($phpWord); + $writer = new ODText($phpWord); $writer->save($file); $this->assertTrue(file_exists($file)); @@ -93,53 +90,53 @@ class ODTextTest extends \PHPUnit_Framework_TestCase } /** - * @covers ::save - * @todo Haven't got any method to test this + * @covers ::save + * @todo Haven't got any method to test this */ public function testSavePhpOutput() { $phpWord = new PHPWord(); $section = $phpWord->createSection(); $section->addText('Test'); - $writer = new PHPWord_Writer_ODText($phpWord); + $writer = new ODText($phpWord); $writer->save('php://output'); } /** - * @covers ::save - * @expectedException Exception - * @expectedExceptionMessage PHPWord object unassigned. + * @covers ::save + * @expectedException Exception + * @expectedExceptionMessage PHPWord object unassigned. */ public function testSaveException() { - $writer = new PHPWord_Writer_ODText(); + $writer = new ODText(); $writer->save(); } /** - * @covers ::getWriterPart + * @covers ::getWriterPart */ public function testGetWriterPartNull() { - $object = new PHPWord_Writer_ODText(); + $object = new ODText(); $this->assertNull($object->getWriterPart('foo')); } /** - * @covers ::setUseDiskCaching - * @covers ::getUseDiskCaching + * @covers ::setUseDiskCaching + * @covers ::getUseDiskCaching */ public function testSetGetUseDiskCaching() { - $object = new PHPWord_Writer_ODText(); + $object = new ODText(); $object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT); $this->assertTrue($object->getUseDiskCaching()); $this->assertEquals(PHPWORD_TESTS_DIR_ROOT, $object->getDiskCachingDirectory()); } /** - * @covers ::setUseDiskCaching - * @expectedException Exception + * @covers ::setUseDiskCaching + * @expectedException Exception */ public function testSetUseDiskCachingException() { @@ -148,7 +145,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase array(\PHPWORD_TESTS_DIR_ROOT, 'foo') ); - $object = new PHPWord_Writer_ODText($phpWord); + $object = new ODText($phpWord); $object->setUseDiskCaching(true, $dir); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/RTFTest.php b/Tests/PHPWord/Writer/RTFTest.php index d071def7..6a7c0780 100644 --- a/Tests/PHPWord/Writer/RTFTest.php +++ b/Tests/PHPWord/Writer/RTFTest.php @@ -1,67 +1,65 @@ assertInstanceOf('PHPWord', $object->getPHPWord()); - $this->assertInstanceOf("PHPWord_HashTable", $object->getDrawingHashTable()); + $this->assertInstanceOf('PhpOffice\\PHPWord', $object->getPHPWord()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\HashTable', $object->getDrawingHashTable()); } /** - * covers ::__construct - * @expectedException Exception - * @expectedExceptionMessage No PHPWord assigned. + * covers ::__construct + * @expectedException Exception + * @expectedExceptionMessage No PHPWord assigned. */ public function testConstructWithNull() { - $object = new PHPWord_Writer_RTF(); + $object = new RTF(); $object->getPHPWord(); } /** - * @covers ::save - * @todo Haven't got any method to test this + * @covers ::save + * @todo Haven't got any method to test this */ public function testSavePhpOutput() { $phpWord = new PHPWord(); $section = $phpWord->createSection(); $section->addText('Test'); - $writer = new PHPWord_Writer_RTF($phpWord); + $writer = new RTF($phpWord); $writer->save('php://output'); } /** - * @covers ::save - * @expectedException Exception - * @expectedExceptionMessage PHPWord object unassigned. + * @covers ::save + * @expectedException Exception + * @expectedExceptionMessage PHPWord object unassigned. */ public function testSaveException() { - $writer = new PHPWord_Writer_RTF(); + $writer = new RTF(); $writer->save(); } /** - * @covers ::save - * @covers :: + * @covers ::save + * @covers :: */ public function testSave() { @@ -97,11 +95,11 @@ class RTFTest extends \PHPUnit_Framework_TestCase $textrun = $section->createTextRun(); $textrun->addText('Test 3'); $textrun->addTextBreak(); - $writer = new PHPWord_Writer_RTF($phpWord); + $writer = new RTF($phpWord); $writer->save($file); $this->assertTrue(file_exists($file)); unlink($file); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/Word2007/BaseTest.php b/Tests/PHPWord/Writer/Word2007/BaseTest.php index fde6e30b..c66ce9ce 100644 --- a/Tests/PHPWord/Writer/Word2007/BaseTest.php +++ b/Tests/PHPWord/Writer/Word2007/BaseTest.php @@ -2,14 +2,11 @@ namespace PHPWord\Tests\Writer\Word2007; use PHPWord; -use PHPWord_Style; use PHPWord\Tests\TestHelperDOCX; /** - * Class BaseTest - * - * @package PHPWord\Tests - * @coversDefaultClass PHPWord_Writer_Word2007_Base + * @package PHPWord\Tests + * @coversDefaultClass PhpOffice\PhpWord\Writer\Word2007\Base * @runTestsInSeparateProcesses */ class BaseTest extends \PHPUnit_Framework_TestCase @@ -23,7 +20,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase } /** - * covers ::_writeText + * covers ::_writeText */ public function testWriteText() { @@ -44,7 +41,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase } /** - * covers ::_writeTextRun + * covers ::_writeTextRun */ public function testWriteTextRun() { @@ -71,7 +68,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase } /** - * covers ::_writeLink + * covers ::_writeLink */ public function testWriteLink() { @@ -88,7 +85,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase } /** - * covers ::_writePreserveText + * covers ::_writePreserveText */ public function testWritePreserveText() { @@ -104,8 +101,9 @@ class BaseTest extends \PHPUnit_Framework_TestCase $this->assertEquals('PAGE', $preserve->nodeValue); $this->assertEquals('preserve', $preserve->getAttribute('xml:space')); } + /** - * covers ::_writeTextBreak + * covers ::_writeTextBreak */ public function testWriteTextBreak() { @@ -130,7 +128,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase } /** - * covers ::_writeParagraphStyle + * covers ::_writeParagraphStyle */ public function testWriteParagraphStyleAlign() { @@ -146,7 +144,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase } /** - * covers ::_writeParagraphStyle + * covers ::_writeParagraphStyle */ public function testWriteParagraphStylePagination() { @@ -176,7 +174,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase } /** - * covers ::_writeTextStyle + * covers ::_writeTextStyle */ public function testWriteFontStyle() { @@ -208,7 +206,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase } /** - * covers ::_writeTableStyle + * covers ::_writeTableStyle */ public function testWriteTableStyle() { @@ -266,7 +264,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase } /** - * covers ::_writeCellStyle + * covers ::_writeCellStyle */ public function testWriteCellStyleCellGridSpan() { @@ -293,7 +291,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase } /** - * covers ::_writeImage + * covers ::_writeImage */ public function testWriteImagePosition() { @@ -318,7 +316,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase } /** - * covers ::_writeWatermark + * covers ::_writeWatermark */ public function testWriteWatermark() { @@ -338,7 +336,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase } /** - * covers ::_writeTitle + * covers ::_writeTitle */ public function testWriteTitle() { @@ -352,4 +350,4 @@ class BaseTest extends \PHPUnit_Framework_TestCase $element = "/w:document/w:body/w:p/w:r/w:fldChar"; $this->assertEquals('end', $doc->getElementAttribute($element, 'w:fldCharType')); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/Word2007/DocumentTest.php b/Tests/PHPWord/Writer/Word2007/DocumentTest.php index fe854fee..70a16dc0 100644 --- a/Tests/PHPWord/Writer/Word2007/DocumentTest.php +++ b/Tests/PHPWord/Writer/Word2007/DocumentTest.php @@ -2,12 +2,9 @@ namespace PHPWord\Tests\Writer\Word2007; use PHPWord; -use PHPWord_Writer_Word2007; -use PHPWord_Writer_Word2007_Document; use PHPWord\Tests\TestHelperDOCX; /** - * Class DocumentTest * @package PHPWord\Tests * @runTestsInSeparateProcesses */ @@ -34,11 +31,11 @@ class DocumentTest extends \PHPUnit_Framework_TestCase } /** - * covers ::_writeTOC - * covers ::_writePageBreak - * covers ::_writeListItem - * covers ::_writeTitle - * covers ::_writeObject + * covers ::_writeTOC + * covers ::_writePageBreak + * covers ::_writeListItem + * covers ::_writeTitle + * covers ::_writeObject */ 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'); $this->assertEquals('Embed', $element->getAttribute('Type')); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/Word2007/FootnotesTest.php b/Tests/PHPWord/Writer/Word2007/FootnotesTest.php index ea49bd67..5ad4b8c7 100644 --- a/Tests/PHPWord/Writer/Word2007/FootnotesTest.php +++ b/Tests/PHPWord/Writer/Word2007/FootnotesTest.php @@ -5,7 +5,6 @@ use PHPWord; use PHPWord\Tests\TestHelperDOCX; /** - * Class PHPWord_Writer_Word2007_FootnotesTest * @package PHPWord\Tests * @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")); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/Word2007/StylesTest.php b/Tests/PHPWord/Writer/Word2007/StylesTest.php index bcdc4b81..026b5eaa 100644 --- a/Tests/PHPWord/Writer/Word2007/StylesTest.php +++ b/Tests/PHPWord/Writer/Word2007/StylesTest.php @@ -5,7 +5,6 @@ use PHPWord; use PHPWord\Tests\TestHelperDOCX; /** - * Class PHPWord_Writer_Word2007_StylesTest * @package PHPWord\Tests * @runTestsInSeparateProcesses */ @@ -68,4 +67,4 @@ class StylesTest extends \PHPUnit_Framework_TestCase $element = $doc->getElement($path, $file); $this->assertEquals('Normal', $element->getAttribute('w:val')); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/Word2007Test.php b/Tests/PHPWord/Writer/Word2007Test.php index 95abee83..34e025d8 100644 --- a/Tests/PHPWord/Writer/Word2007Test.php +++ b/Tests/PHPWord/Writer/Word2007Test.php @@ -1,15 +1,13 @@ assertInstanceOf( - "PHPWord_Writer_Word2007_{$part}", + "PhpOffice\\PhpWord\\Writer\\Word2007\\{$part}", $object->getWriterPart($part) ); $this->assertInstanceOf( - "PHPWord_Writer_Word2007", + 'PhpOffice\\PhpWord\\Writer\\Word2007', $object->getWriterPart($part)->getParentWriter() ); } } /** - * @covers ::save + * @covers ::save */ public function testSave() { @@ -57,7 +64,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase $textrun = $section->createTextRun(); $textrun->addText('Test 3'); - $writer = new PHPWord_Writer_Word2007($phpWord); + $writer = new Word2007($phpWord); $file = \join( \DIRECTORY_SEPARATOR, 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() { @@ -98,20 +105,20 @@ class Word2007Test extends \PHPUnit_Framework_TestCase } /** - * @covers ::setUseDiskCaching - * @covers ::getUseDiskCaching + * @covers ::setUseDiskCaching + * @covers ::getUseDiskCaching */ public function testSetGetUseDiskCaching() { - $object = new PHPWord_Writer_Word2007(); + $object = new Word2007(); $object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT); $this->assertTrue($object->getUseDiskCaching()); } /** - * @covers ::setUseDiskCaching - * @expectedException Exception + * @covers ::setUseDiskCaching + * @expectedException Exception */ public function testSetUseDiskCachingException() { @@ -120,7 +127,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase array(\PHPWORD_TESTS_DIR_ROOT, 'foo') ); - $object = new PHPWord_Writer_Word2007(); + $object = new Word2007(); $object->setUseDiskCaching(true, $dir); } -} +} \ No newline at end of file diff --git a/Tests/PHPWordTest.php b/Tests/PHPWordTest.php index 15106af6..4ab63075 100644 --- a/Tests/PHPWordTest.php +++ b/Tests/PHPWordTest.php @@ -1,38 +1,33 @@ assertEquals( - new PHPWord_DocumentProperties(), - $object->getProperties() - ); + $this->assertEquals(new DocumentProperties(), $object->getProperties()); $this->assertEquals( PHPWord::DEFAULT_FONT_NAME, $object->getDefaultFontName() @@ -44,8 +39,8 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase } /** - * @covers PHPWord::setProperties - * @covers PHPWord::getProperties + * @covers ::setProperties + * @covers ::getProperties */ public function testSetGetProperties() { @@ -58,20 +53,20 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase } /** - * @covers PHPWord::createSection - * @covers PHPWord::getSections + * @covers ::createSection + * @covers ::getSections */ public function testCreateGetSections() { $object = new PHPWord(); - $this->assertEquals(new PHPWord_Section(1), $object->createSection()); + $this->assertEquals(new Section(1), $object->createSection()); $object->createSection(); $this->assertEquals(2, count($object->getSections())); } /** - * @covers PHPWord::setDefaultFontName - * @covers PHPWord::getDefaultFontName + * @covers ::setDefaultFontName + * @covers ::getDefaultFontName */ public function testSetGetDefaultFontName() { @@ -86,8 +81,8 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase } /** - * @covers PHPWord::setDefaultFontSize - * @covers PHPWord::getDefaultFontSize + * @covers ::setDefaultFontSize + * @covers ::getDefaultFontSize */ public function testSetGetDefaultFontSize() { @@ -102,45 +97,42 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase } /** - * @covers PHPWord::setDefaultParagraphStyle - * @covers PHPWord::loadTemplate + * @covers ::setDefaultParagraphStyle + * @covers ::loadTemplate */ public function testSetDefaultParagraphStyle() { $object = new PHPWord(); $object->setDefaultParagraphStyle(array()); - $this->assertInstanceOf( - 'PHPWord_Style_Paragraph', - PHPWord_Style::getStyle('Normal') - ); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', Style::getStyle('Normal')); } /** - * @covers PHPWord::addParagraphStyle - * @covers PHPWord::addFontStyle - * @covers PHPWord::addTableStyle - * @covers PHPWord::addLinkStyle + * @covers ::addParagraphStyle + * @covers ::addFontStyle + * @covers ::addTableStyle + * @covers ::addLinkStyle */ public function testAddStyles() { $object = new PHPWord(); - $styles = array('Paragraph' => 'Paragraph', 'Font' => 'Font', - 'Table' => 'TableFull', 'Link' => 'Font'); + $styles = array( + 'Paragraph' => 'Paragraph', + 'Font' => 'Font', + 'Table' => 'TableFull', + 'Link' => 'Font', + ); foreach ($styles as $key => $value) { $method = "add{$key}Style"; $styleId = "{$key} Style"; - $styleType = "PHPWord_Style_{$value}"; $object->$method($styleId, array()); - $this->assertInstanceOf( - $styleType, - PHPWord_Style::getStyle($styleId) - ); + $this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$value}", Style::getStyle($styleId)); } } /** - * @covers PHPWord::addTitleStyle + * @covers ::addTitleStyle */ public function testAddTitleStyle() { @@ -148,14 +140,11 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase $titleLevel = 1; $titleName = "Heading_{$titleLevel}"; $object->addTitleStyle($titleLevel, array()); - $this->assertInstanceOf( - 'PHPWord_Style_Font', - PHPWord_Style::getStyle($titleName) - ); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', Style::getStyle($titleName)); } /** - * @covers PHPWord::loadTemplate + * @covers ::loadTemplate */ public function testLoadTemplate() { @@ -164,15 +153,12 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx') ); $object = new PHPWord(); - $this->assertInstanceOf( - 'PHPWord_Template', - $object->loadTemplate($file) - ); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Template', $object->loadTemplate($file)); } /** - * @covers PHPWord::loadTemplate - * @expectedException PHPWord_Exception + * @covers ::loadTemplate + * @expectedException PhpOffice\PhpWord\Exceptions\Exception */ public function testLoadTemplateException() { @@ -183,4 +169,4 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase $object = new PHPWord(); $object->loadTemplate($file); } -} +} \ No newline at end of file diff --git a/Tests/_inc/TestHelperDOCX.php b/Tests/_inc/TestHelperDOCX.php index dec1f077..086a1227 100644 --- a/Tests/_inc/TestHelperDOCX.php +++ b/Tests/_inc/TestHelperDOCX.php @@ -2,6 +2,7 @@ namespace PHPWord\Tests; use PHPWord; +use PhpOffice\PhpWord\IOFactory; class TestHelperDOCX { @@ -19,8 +20,8 @@ class TestHelperDOCX mkdir(sys_get_temp_dir() . '/PHPWord_Unit_Test/'); } - $objWriter = \PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save(self::$file); + $xmlWriter = IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save(self::$file); $zip = new \ZipArchive; $res = $zip->open(self::$file); diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php index 10f129db..f9e08794 100755 --- a/samples/Sample_01_SimpleText.php +++ b/samples/Sample_01_SimpleText.php @@ -52,11 +52,11 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } // Done 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; \ No newline at end of file diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php index e9e2d84b..6bbbe0bb 100755 --- a/samples/Sample_02_TabStops.php +++ b/samples/Sample_02_TabStops.php @@ -11,19 +11,19 @@ $PHPWord = new PHPWord(); // Ads styles $PHPWord->addParagraphStyle('multipleTab', array( 'tabs' => array( - new PHPWord_Style_Tab('left', 1550), - new PHPWord_Style_Tab('center', 3200), - new PHPWord_Style_Tab('right', 5300) + new PhpOffice\PhpWord\Style\Tab('left', 1550), + new PhpOffice\PhpWord\Style\Tab('center', 3200), + new PhpOffice\PhpWord\Style\Tab('right', 5300) ) )); $PHPWord->addParagraphStyle('rightTab', array( 'tabs' => array( - new PHPWord_Style_Tab('right', 9090) + new PhpOffice\PhpWord\Style\Tab('right', 9090) ) )); $PHPWord->addParagraphStyle('centerTab', 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'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_03_Sections.php b/samples/Sample_03_Sections.php index 1e49629e..9c23e981 100755 --- a/samples/Sample_03_Sections.php +++ b/samples/Sample_03_Sections.php @@ -33,8 +33,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_04_Textrun.php b/samples/Sample_04_Textrun.php index b30db7a5..64625ac5 100644 --- a/samples/Sample_04_Textrun.php +++ b/samples/Sample_04_Textrun.php @@ -8,12 +8,11 @@ require_once '../Classes/PHPWord.php'; echo date('H:i:s') , ' Create new PHPWord object' , EOL; $PHPWord = new PHPWord(); - // Ads styles $PHPWord->addParagraphStyle('pStyle', array('spacing'=>100)); $PHPWord->addFontStyle('BoldText', array('bold'=>true)); $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 $section = $PHPWord->createSection(); @@ -40,8 +39,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_05_Multicolumn.php b/samples/Sample_05_Multicolumn.php index 3877defe..1fdae0cf 100644 --- a/samples/Sample_05_Multicolumn.php +++ b/samples/Sample_05_Multicolumn.php @@ -43,8 +43,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_06_Footnote.php b/samples/Sample_06_Footnote.php index daaa6b46..a0b33545 100755 --- a/samples/Sample_06_Footnote.php +++ b/samples/Sample_06_Footnote.php @@ -15,7 +15,7 @@ $section = $PHPWord->createSection(); $PHPWord->addParagraphStyle('pStyle', array('spacing'=>100)); $PHPWord->addFontStyle('BoldText', array('bold'=>true)); $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 $textrun = $section->createTextRun('pStyle'); @@ -41,8 +41,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php index edd1992c..c29c18a8 100644 --- a/samples/Sample_08_ParagraphPagination.php +++ b/samples/Sample_08_ParagraphPagination.php @@ -9,7 +9,7 @@ echo date('H:i:s') , " Create new PHPWord object" , EOL; $PHPWord = new PHPWord(); $PHPWord->setDefaultParagraphStyle(array( 'align' => 'both', - 'spaceAfter' => PHPWord_Shared_Font::pointSizeToTwips(12), + 'spaceAfter' => PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(12), 'spacing' => 120, )); @@ -53,8 +53,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php index 96e411a0..338e1fa4 100644 --- a/samples/Sample_09_Tables.php +++ b/samples/Sample_09_Tables.php @@ -32,7 +32,7 @@ $section->addText("Fancy table", $header); $styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80); $styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF'); $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'); $PHPWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow); $table = $section->addTable('Fancy Table'); @@ -81,8 +81,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_10_EastAsianFontStyle.php b/samples/Sample_10_EastAsianFontStyle.php index 8be72109..f6227005 100644 --- a/samples/Sample_10_EastAsianFontStyle.php +++ b/samples/Sample_10_EastAsianFontStyle.php @@ -17,8 +17,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_11_ReadWord2007.php b/samples/Sample_11_ReadWord2007.php index d96e9264..e5a54253 100644 --- a/samples/Sample_11_ReadWord2007.php +++ b/samples/Sample_11_ReadWord2007.php @@ -8,14 +8,14 @@ require_once '../Classes/PHPWord.php'; $name = basename(__FILE__, '.php'); $source = "resources/{$name}.docx"; echo date('H:i:s'), " Reading contents from `{$source}`", EOL; -$PHPWord = PHPWord_IOFactory::load($source); +$PHPWord = PhpOffice\PhpWord\IOFactory::load($source); // (Re)write contents $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php index b0d0e137..7cfbad8e 100644 --- a/samples/Sample_12_HeaderFooter.php +++ b/samples/Sample_12_HeaderFooter.php @@ -64,8 +64,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php index 0f64cb7b..e5229c90 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -32,8 +32,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_14_ListItem.php b/samples/Sample_14_ListItem.php index fa648784..7624e150 100644 --- a/samples/Sample_14_ListItem.php +++ b/samples/Sample_14_ListItem.php @@ -31,7 +31,7 @@ $section->addListItem('List Item 1.3.2', 2); $section->addTextBreak(2); // 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 2', 0, null, $listStyle); $section->addListItem('List Item 3', 0, null, $listStyle); @@ -40,7 +40,7 @@ $section->addTextBreak(2); // Add listitem elements $PHPWord->addFontStyle('myOwnStyle', array('color'=>'FF0000')); $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 2', 0, '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'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_15_Link.php b/samples/Sample_15_Link.php index ef631906..08ef742a 100644 --- a/samples/Sample_15_Link.php +++ b/samples/Sample_15_Link.php @@ -16,7 +16,7 @@ $PHPWord = new PHPWord(); $section = $PHPWord->createSection(); // 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); $PHPWord->addLinkStyle('myOwnLinkStyle', array('bold'=>true, 'color'=>'808000')); @@ -30,8 +30,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_16_Object.php b/samples/Sample_16_Object.php index e04c49e5..d1d18fb6 100644 --- a/samples/Sample_16_Object.php +++ b/samples/Sample_16_Object.php @@ -25,8 +25,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_17_TitleTOC.php b/samples/Sample_17_TitleTOC.php index efa756e4..0189bfce 100644 --- a/samples/Sample_17_TitleTOC.php +++ b/samples/Sample_17_TitleTOC.php @@ -57,8 +57,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_18_Watermark.php b/samples/Sample_18_Watermark.php index 8332bd03..06195567 100644 --- a/samples/Sample_18_Watermark.php +++ b/samples/Sample_18_Watermark.php @@ -26,8 +26,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_19_TextBreak.php b/samples/Sample_19_TextBreak.php index 17299601..3863dfb9 100644 --- a/samples/Sample_19_TextBreak.php +++ b/samples/Sample_19_TextBreak.php @@ -39,8 +39,8 @@ $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save("{$name}.{$extension}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); }