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
*/
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

View File

@ -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++;
// }
}

View File

@ -1,11 +1,9 @@
<?php
namespace PHPWord\Tests\Shared;
use PHPWord_Shared_Drawing;
use PhpOffice\PhpWord\Shared\Drawing;
/**
* Class DrawingTest
*
* @package PHPWord\Tests
* @runTestsInSeparateProcesses
*/
@ -21,28 +19,28 @@ class DrawingTest extends \PHPUnit_Framework_TestCase
$values[] = rand(1, 100); // integer
foreach ($values as $value) {
$result = PHPWord_Shared_Drawing::pixelsToEMU($value);
$result = Drawing::pixelsToEMU($value);
$this->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,7 +57,7 @@ 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);
}
}

View File

@ -1,13 +1,11 @@
<?php
namespace PHPWord\Tests\Shared;
use PHPWord_Shared_File;
use PhpOffice\PhpWord\Shared\File;
/**
* Class FileTest
*
* @package PHPWord\Tests
* @coversDefaultClass PHPWord_Shared_File
* @package PHPWord\Tests
* @coversDefaultClass PhpOffice\PhpWord\Shared\File
* @runTestsInSeparateProcesses
*/
class FileTest extends \PHPUnit_Framework_TestCase
@ -17,26 +15,18 @@ class FileTest extends \PHPUnit_Framework_TestCase
*/
public function testFileExists()
{
$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->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));
}
}

View File

@ -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);
}
}

View File

@ -1,33 +1,31 @@
<?php
namespace PHPWord\Tests\Shared;
use PHPWord_Shared_String;
use PhpOffice\PhpWord\Shared\String;
/**
* Class StringTest
*
* @package PHPWord\Tests
* @coversDefaultClass PHPWord_Shared_String
* @package PHPWord\Tests
* @coversDefaultClass PhpOffice\PhpWord\Shared\String
* @runTestsInSeparateProcesses
*/
class StringTest extends \PHPUnit_Framework_TestCase
{
public function testIsUTF8()
{
$this->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)));
}
}

View File

@ -1,11 +1,9 @@
<?php
namespace PHPWord\Tests\Style;
use PHPWord_Style_Cell;
use PhpOffice\PhpWord\Style\Cell;
/**
* Class CellTest
*
* @package PHPWord\Tests
* @runTestsInSeparateProcesses
*/
@ -16,11 +14,11 @@ class CellTest extends \PHPUnit_Framework_TestCase
*/
public function testSetGetNormal()
{
$object = new PHPWord_Style_Cell();
$object = new Cell();
$attributes = array(
'valign' => '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,7 +64,7 @@ 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);

View File

@ -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',

View File

@ -1,11 +1,9 @@
<?php
namespace PHPWord\Tests\Style;
use PHPWord_Style_Image;
use PhpOffice\PhpWord\Style\Image;
/**
* Class ImageTest
*
* @package PHPWord\Tests
* @runTestsInSeparateProcesses
*/
@ -16,7 +14,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
*/
public function testSetGetNormal()
{
$object = new PHPWord_Style_Image();
$object = new Image();
$properties = array(
'width' => 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');
}
}

View File

@ -1,11 +1,9 @@
<?php
namespace PHPWord\Tests\Style;
use PHPWord_Style_ListItem;
use PhpOffice\PhpWord\Style\ListItem;
/**
* Class ListItemTest
*
* @package PHPWord\Tests
* @runTestsInSeparateProcesses
*/
@ -16,9 +14,9 @@ class ListItemTest extends \PHPUnit_Framework_TestCase
*/
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());
}
@ -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,9 +37,9 @@ 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());
}

View File

@ -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,7 +123,7 @@ 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());
}

View File

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

View File

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

View File

@ -1,11 +1,9 @@
<?php
namespace PHPWord\Tests\Style;
use PHPWord_Style_TableFull;
use PhpOffice\PhpWord\Style\TableFull;
/**
* Class TableFullTest
*
* @package PHPWord\Tests
* @runTestsInSeparateProcesses
*/
@ -24,11 +22,11 @@ class TableFullTest extends \PHPUnit_Framework_TestCase
$styleTable = array('bgColor' => '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;

View File

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

View File

@ -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]';

View File

@ -1,22 +1,20 @@
<?php
namespace PHPWord\Tests;
use PHPWord_Style;
use PhpOffice\PhpWord\Style;
/**
* Class StyleTest
*
* @package PHPWord\Tests
* @covers PHPWord_Style
* @package PHPWord\Tests
* @coversDefaultClass PhpOffice\PhpWord\Style
* @runTestsInSeparateProcesses
*/
class StyleTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers PHPWord_Style::addParagraphStyle
* @covers PHPWord_Style::addFontStyle
* @covers PHPWord_Style::addLinkStyle
* @covers PHPWord_Style::addTitleStyle
* @covers ::addParagraphStyle
* @covers ::addFontStyle
* @covers ::addLinkStyle
* @covers ::addTitleStyle
*/
public function testStyles()
{
@ -27,18 +25,17 @@ class StyleTest extends \PHPUnit_Framework_TestCase
'Link' => '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'));
}
}

View File

@ -1,38 +1,35 @@
<?php
namespace PHPWord\Tests;
use PHPWord_TOC;
use PHPWord_Style_TOC;
use PhpOffice\PhpWord\TOC;
/**
* Class TOCTest
*
* @package PHPWord\Tests
* @covers PHPWord_TOC
* @package PHPWord\Tests
* @coversDefaultClass PhpOffice\PhpWord\TOC
* @runTestsInSeparateProcesses
*/
class TOCTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers PHPWord_TOC::__construct
* @covers PHPWord_TOC::getStyleTOC
* @covers PHPWord_TOC::getStyleFont
* @covers ::__construct
* @covers ::getStyleTOC
* @covers ::getStyleFont
*/
public function testConstruct()
{
$expected = array(
'tabPos' => 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,16 +53,16 @@ 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']);

View File

@ -1,11 +1,11 @@
<?php
namespace PHPWord\Tests;
use PHPWord_Template;
use PhpOffice\PhpWord\Template;
use PHPWord;
/**
* @coversDefaultClass PHPWord_Template
* @coversDefaultClass PhpOffice\PhpWord\Template
*/
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')
);
$document = new PHPWord_Template($templateFqfn);
$document = new Template($templateFqfn);
$xslDOMDocument = new \DOMDocument();
$xslDOMDocument->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')

View File

@ -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 <private>
* covers ::writeContent
* covers <private>
*/
public function testWriteContent()
{

View File

@ -1,14 +1,12 @@
<?php
namespace PHPWord\Tests\Writer;
use PHPWord_Writer_ODText;
use PhpOffice\PhpWord\Writer\ODText;
use PHPWord;
/**
* Class ODTextTest
*
* @package PHPWord\Tests
* @coversDefaultClass PHPWord_Writer_ODText
* @package PHPWord\Tests
* @coversDefaultClass PhpOffice\PhpWord\Writer\ODText
* @runTestsInSeparateProcesses
*/
class ODTextTest extends \PHPUnit_Framework_TestCase
@ -18,38 +16,37 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
*/
public function testConstruct()
{
$object = new PHPWord_Writer_ODText(new PHPWord());
$object = new ODText(new PHPWord());
$this->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);
}
}

View File

@ -1,67 +1,65 @@
<?php
namespace PHPWord\Tests\Writer;
use PHPWord_Writer_RTF;
use PhpOffice\PhpWord\Writer\RTF;
use PHPWord;
/**
* Class RTFTest
*
* @package PHPWord\Tests
* @coversDefaultClass PHPWord_Writer_RTF
* @package PHPWord\Tests
* @coversDefaultClass PhpOffice\PhpWord\Writer\RTF
* @runTestsInSeparateProcesses
*/
class RTFTest extends \PHPUnit_Framework_TestCase
{
/**
* covers ::construct
* covers ::construct
*/
public function testConstruct()
{
$object = new PHPWord_Writer_RTF(new PHPWord);
$object = new RTF(new PHPWord);
$this->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 ::<private>
* @covers ::save
* @covers ::<private>
*/
public function testSave()
{
@ -97,7 +95,7 @@ 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));

View File

@ -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()
{

View File

@ -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()
{

View File

@ -5,7 +5,6 @@ use PHPWord;
use PHPWord\Tests\TestHelperDOCX;
/**
* Class PHPWord_Writer_Word2007_FootnotesTest
* @package PHPWord\Tests
* @runTestsInSeparateProcesses
*/

View File

@ -5,7 +5,6 @@ use PHPWord;
use PHPWord\Tests\TestHelperDOCX;
/**
* Class PHPWord_Writer_Word2007_StylesTest
* @package PHPWord\Tests
* @runTestsInSeparateProcesses
*/

View File

@ -1,15 +1,13 @@
<?php
namespace PHPWord\Tests\Writer;
use PHPWord_Writer_Word2007;
use PhpOffice\PhpWord\Writer\Word2007;
use PHPWord;
use PHPWord\Tests\TestHelperDOCX;
/**
* Class Word2007Test
*
* @package PHPWord\Tests
* @coversDefaultClass PHPWord_Writer_Word2007
* @package PHPWord\Tests
* @coversDefaultClass PhpOffice\PhpWord\Writer\Word2007
* @runTestsInSeparateProcesses
*/
class Word2007Test extends \PHPUnit_Framework_TestCase
@ -20,29 +18,38 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
}
/**
* covers ::__construct
* covers ::__construct
*/
public function testConstruct()
{
$object = new PHPWord_Writer_Word2007(new PHPWord());
$object = new Word2007(new PHPWord());
$writerParts = array('ContentTypes', 'Rels', 'DocProps',
'DocumentRels', 'Document', 'Styles', 'Header', 'Footer',
'Footnotes', 'FootnotesRels');
$writerParts = array(
'ContentTypes',
'Rels',
'DocProps',
'DocumentRels',
'Document',
'Styles',
'Header',
'Footer',
'Footnotes',
'FootnotesRels',
);
foreach ($writerParts as $part) {
$this->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);
}
}

View File

@ -1,38 +1,33 @@
<?php
namespace PHPWord\Tests;
use PHPWord;
use PHPWord_DocumentProperties;
use PHPWord_Section;
use PHPWord_Style;
use PhpOffice\PHPWord;
use PhpOffice\PhpWord\DocumentProperties;
use PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Style;
/**
* Class PHPWordTest
*
* @package PHPWord\Tests
* @covers PHPWord
* @package PHPWord\Tests
* @coversDefaultClass PhpOffice\PHPWord
* @runTestsInSeparateProcesses
*/
class PHPWordTest extends \PHPUnit_Framework_TestCase
{
/**
* @var PHPWord
* @var PhpOffice\PHPWord
*/
protected $object;
/**
* @covers PHPWord::__construct
* @covers PHPWord::getProperties
* @covers PHPWord::getDefaultFontName
* @covers PHPWord::getDefaultFontSize
* @covers ::__construct
* @covers ::getProperties
* @covers ::getDefaultFontName
* @covers ::getDefaultFontSize
*/
public function testConstruct()
{
$object = new PHPWord();
$this->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()
{

View File

@ -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);

View File

@ -52,8 +52,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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}

View File

@ -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}");
}