Merge pull request #95 from gabrielbull/develop
Removed fake namespacing from tests and reformatted code to PSR-2 coding standards
This commit is contained in:
commit
88836672c3
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
namespace PHPWord\Exceptions;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InvalidStyleException
|
||||||
|
*
|
||||||
|
* Exception used for when a style value is invalid
|
||||||
|
*
|
||||||
|
* @package PHPWord
|
||||||
|
*/
|
||||||
|
class InvalidStyleException extends InvalidArgumentException
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -48,7 +48,7 @@ class PHPWord_Section_Text
|
||||||
/**
|
/**
|
||||||
* Paragraph style
|
* Paragraph style
|
||||||
*
|
*
|
||||||
* @var PHPWord_Style_Font
|
* @var \PHPWord_Style_Paragraph
|
||||||
*/
|
*/
|
||||||
private $_styleParagraph;
|
private $_styleParagraph;
|
||||||
|
|
||||||
|
|
@ -116,7 +116,9 @@ class PHPWord_Section_Text
|
||||||
/**
|
/**
|
||||||
* Set Paragraph style
|
* Set Paragraph style
|
||||||
*
|
*
|
||||||
* @return PHPWord_Style_Paragraph
|
* @param array|\PHPWord_Style_Paragraph $styleParagraph
|
||||||
|
* @return \PHPWord_Style_Paragraph
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function setParagraphStyle($styleParagraph)
|
public function setParagraphStyle($styleParagraph)
|
||||||
{
|
{
|
||||||
|
|
@ -124,14 +126,19 @@ class PHPWord_Section_Text
|
||||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||||
|
|
||||||
foreach ($styleParagraph as $key => $value) {
|
foreach ($styleParagraph as $key => $value) {
|
||||||
if (substr($key, 0, 1) != '_') {
|
if ($key === 'line-height') {
|
||||||
|
null;
|
||||||
|
} elseif (substr($key, 0, 1) != '_') {
|
||||||
$key = '_' . $key;
|
$key = '_' . $key;
|
||||||
}
|
}
|
||||||
$this->_styleParagraph->setStyleValue($key, $value);
|
$this->_styleParagraph->setStyleValue($key, $value);
|
||||||
}
|
}
|
||||||
} else {
|
} elseif ($styleParagraph instanceof PHPWord_Style_Paragraph) {
|
||||||
$this->_styleParagraph = $styleParagraph;
|
$this->_styleParagraph = $styleParagraph;
|
||||||
|
} else {
|
||||||
|
throw new Exception('Expected array or PHPWord_Style_Paragraph');
|
||||||
}
|
}
|
||||||
|
return $this->_styleParagraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@
|
||||||
*/
|
*/
|
||||||
class PHPWord_Style_Font
|
class PHPWord_Style_Font
|
||||||
{
|
{
|
||||||
|
|
||||||
const UNDERLINE_NONE = 'none';
|
const UNDERLINE_NONE = 'none';
|
||||||
const UNDERLINE_DASH = 'dash';
|
const UNDERLINE_DASH = 'dash';
|
||||||
const UNDERLINE_DASHHEAVY = 'dashHeavy';
|
const UNDERLINE_DASHHEAVY = 'dashHeavy';
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,21 @@
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use PHPWord\Exceptions\InvalidStyleException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_Style_Paragraph
|
* PHPWord_Style_Paragraph
|
||||||
*/
|
*/
|
||||||
class PHPWord_Style_Paragraph
|
class PHPWord_Style_Paragraph
|
||||||
{
|
{
|
||||||
|
const LINE_HEIGHT = 240;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Text line height
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $lineHeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paragraph alignment
|
* Paragraph alignment
|
||||||
|
|
@ -85,7 +95,7 @@ class PHPWord_Style_Paragraph
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_basedOn;
|
private $_basedOn = 'Normal';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Style for next paragraph
|
* Style for next paragraph
|
||||||
|
|
@ -99,48 +109,28 @@ class PHPWord_Style_Paragraph
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $_widowControl;
|
private $_widowControl = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keep paragraph with next paragraph
|
* Keep paragraph with next paragraph
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $_keepNext;
|
private $_keepNext = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keep all lines on one page
|
* Keep all lines on one page
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $_keepLines;
|
private $_keepLines = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start paragraph on next page
|
* Start paragraph on next page
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $_pageBreakBefore;
|
private $_pageBreakBefore = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* New Paragraph Style
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->_align = null;
|
|
||||||
$this->_spaceBefore = null;
|
|
||||||
$this->_spaceAfter = null;
|
|
||||||
$this->_spacing = null;
|
|
||||||
$this->_tabs = null;
|
|
||||||
$this->_indent = null;
|
|
||||||
$this->_hanging = null;
|
|
||||||
$this->_basedOn = 'Normal';
|
|
||||||
$this->_next = null;
|
|
||||||
$this->_widowControl = true;
|
|
||||||
$this->_keepNext = false;
|
|
||||||
$this->_keepLines = false;
|
|
||||||
$this->_pageBreakBefore = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Style value
|
* Set Style value
|
||||||
|
|
@ -152,10 +142,13 @@ class PHPWord_Style_Paragraph
|
||||||
{
|
{
|
||||||
if ($key == '_indent' || $key == '_hanging') {
|
if ($key == '_indent' || $key == '_hanging') {
|
||||||
$value = $value * 720;
|
$value = $value * 720;
|
||||||
}
|
} elseif ($key == '_spacing') {
|
||||||
if ($key == '_spacing') {
|
|
||||||
$value += 240; // because line height of 1 matches 240 twips
|
$value += 240; // because line height of 1 matches 240 twips
|
||||||
|
} elseif ($key === 'line-height') {
|
||||||
|
$this->setLineHeight($value);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
$this->$key = $value;
|
||||||
$method = 'set' . substr($key, 1);
|
$method = 'set' . substr($key, 1);
|
||||||
if (method_exists($this, $method)) {
|
if (method_exists($this, $method)) {
|
||||||
$this->$method($value);
|
$this->$method($value);
|
||||||
|
|
@ -466,4 +459,33 @@ class PHPWord_Style_Paragraph
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the line height
|
||||||
|
*
|
||||||
|
* @param int|float|string $lineHeight
|
||||||
|
* @return $this
|
||||||
|
* @throws \PHPWord\Exceptions\InvalidStyleException
|
||||||
|
*/
|
||||||
|
public function setLineHeight($lineHeight)
|
||||||
|
{
|
||||||
|
if (is_string($lineHeight)) {
|
||||||
|
$lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!is_integer($lineHeight) && !is_float($lineHeight)) || !$lineHeight) {
|
||||||
|
throw new InvalidStyleException('Line height must be a valid number');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->lineHeight = $lineHeight;
|
||||||
|
$this->setSpacing($lineHeight * self::LINE_HEIGHT);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getLineHeight()
|
||||||
|
{
|
||||||
|
return $this->lineHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,22 +5,24 @@ use PHPUnit_Framework_TestCase;
|
||||||
use PHPWord;
|
use PHPWord;
|
||||||
use PHPWord_IOFactory;
|
use PHPWord_IOFactory;
|
||||||
use PHPWord_Writer_Word2007;
|
use PHPWord_Writer_Word2007;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PHPWord_IOFactoryTest
|
* Class IOFactoryTest
|
||||||
* @package PHPWord\Tests
|
* @package PHPWord\Tests
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class PHPWord_IOFactoryTest extends \PHPUnit_Framework_TestCase {
|
class IOFactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
public function testGetSearchLocations()
|
public function testGetSearchLocations()
|
||||||
{
|
{
|
||||||
$this->assertAttributeEquals(PHPWord_IOFactory::getSearchLocations(), '_searchLocations','PHPWord_IOFactory');
|
$this->assertAttributeEquals(PHPWord_IOFactory::getSearchLocations(), '_searchLocations', 'PHPWord_IOFactory');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetSearchLocationsWithArray()
|
public function testSetSearchLocationsWithArray()
|
||||||
{
|
{
|
||||||
PHPWord_IOFactory::setSearchLocations(array());
|
PHPWord_IOFactory::setSearchLocations(array());
|
||||||
$this->assertAttributeEquals(array(), '_searchLocations','PHPWord_IOFactory');
|
$this->assertAttributeEquals(array(), '_searchLocations', 'PHPWord_IOFactory');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -36,24 +38,25 @@ class PHPWord_IOFactoryTest extends \PHPUnit_Framework_TestCase {
|
||||||
{
|
{
|
||||||
PHPWord_IOFactory::setSearchLocations(array());
|
PHPWord_IOFactory::setSearchLocations(array());
|
||||||
PHPWord_IOFactory::addSearchLocation('type', 'location', 'classname');
|
PHPWord_IOFactory::addSearchLocation('type', 'location', 'classname');
|
||||||
$this->assertAttributeEquals(array(array('type' => 'type', 'path' => 'location', 'class' => 'classname')), '_searchLocations','PHPWord_IOFactory');
|
$this->assertAttributeEquals(array(array('type' => 'type', 'path' => 'location', 'class' => 'classname')), '_searchLocations', 'PHPWord_IOFactory');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Exception
|
* @expectedException Exception
|
||||||
* @expectedExceptionMessage No IWriter found for type
|
* @expectedExceptionMessage No IWriter found for type
|
||||||
*/
|
*/
|
||||||
public function testCreateWriterException(){
|
public function testCreateWriterException()
|
||||||
|
{
|
||||||
$oPHPWord = new PHPWord();
|
$oPHPWord = new PHPWord();
|
||||||
|
|
||||||
PHPWord_IOFactory::setSearchLocations(array());
|
PHPWord_IOFactory::setSearchLocations(array());
|
||||||
PHPWord_IOFactory::createWriter($oPHPWord);
|
PHPWord_IOFactory::createWriter($oPHPWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateWriter(){
|
public function testCreateWriter()
|
||||||
|
{
|
||||||
$oPHPWord = new PHPWord();
|
$oPHPWord = new PHPWord();
|
||||||
|
|
||||||
$this->assertEquals(PHPWord_IOFactory::createWriter($oPHPWord, 'Word2007'), new PHPWord_Writer_Word2007($oPHPWord));
|
$this->assertEquals(PHPWord_IOFactory::createWriter($oPHPWord, 'Word2007'), new PHPWord_Writer_Word2007($oPHPWord));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4,8 +4,8 @@ namespace PHPWord\Tests;
|
||||||
use PHPUnit_Framework_TestCase;
|
use PHPUnit_Framework_TestCase;
|
||||||
use PHPWord_Media;
|
use PHPWord_Media;
|
||||||
|
|
||||||
class PHPWord_MediaTest extends \PHPUnit_Framework_TestCase {
|
class MediaTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
public function testGetSectionMediaElementsWithNull()
|
public function testGetSectionMediaElementsWithNull()
|
||||||
{
|
{
|
||||||
$this->assertEquals(PHPWord_Media::getSectionMediaElements(), array());
|
$this->assertEquals(PHPWord_Media::getSectionMediaElements(), array());
|
||||||
|
|
@ -18,12 +18,11 @@ class PHPWord_MediaTest extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
public function testGetHeaderMediaElements()
|
public function testGetHeaderMediaElements()
|
||||||
{
|
{
|
||||||
$this->assertAttributeEquals(PHPWord_Media::getHeaderMediaElements(), '_headerMedia','PHPWord_Media');
|
$this->assertAttributeEquals(PHPWord_Media::getHeaderMediaElements(), '_headerMedia', 'PHPWord_Media');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetFooterMediaElements()
|
public function testGetFooterMediaElements()
|
||||||
{
|
{
|
||||||
$this->assertAttributeEquals(PHPWord_Media::getFooterMediaElements(), '_footerMedia','PHPWord_Media');
|
$this->assertAttributeEquals(PHPWord_Media::getFooterMediaElements(), '_footerMedia', 'PHPWord_Media');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4,7 +4,8 @@ namespace PHPWord\Tests;
|
||||||
use PHPUnit_Framework_TestCase;
|
use PHPUnit_Framework_TestCase;
|
||||||
use PHPWord_Section;
|
use PHPWord_Section;
|
||||||
|
|
||||||
class PHPWord_SectionTest extends \PHPUnit_Framework_TestCase {
|
class SectionTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
public function testGetSettings()
|
public function testGetSettings()
|
||||||
{
|
{
|
||||||
$oSection = new PHPWord_Section(0);
|
$oSection = new PHPWord_Section(0);
|
||||||
|
|
@ -14,25 +15,24 @@ class PHPWord_SectionTest extends \PHPUnit_Framework_TestCase {
|
||||||
public function testGetElementss()
|
public function testGetElementss()
|
||||||
{
|
{
|
||||||
$oSection = new PHPWord_Section(0);
|
$oSection = new PHPWord_Section(0);
|
||||||
$this->assertAttributeEquals($oSection->getElements(), '_elementCollection',new PHPWord_Section(0));
|
$this->assertAttributeEquals($oSection->getElements(), '_elementCollection', new PHPWord_Section(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetFooter()
|
public function testGetFooter()
|
||||||
{
|
{
|
||||||
$oSection = new PHPWord_Section(0);
|
$oSection = new PHPWord_Section(0);
|
||||||
$this->assertAttributeEquals($oSection->getFooter(), '_footer',new PHPWord_Section(0));
|
$this->assertAttributeEquals($oSection->getFooter(), '_footer', new PHPWord_Section(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetHeaders()
|
public function testGetHeaders()
|
||||||
{
|
{
|
||||||
$oSection = new PHPWord_Section(0);
|
$oSection = new PHPWord_Section(0);
|
||||||
$this->assertAttributeEquals($oSection->getHeaders(), '_headers',new PHPWord_Section(0));
|
$this->assertAttributeEquals($oSection->getHeaders(), '_headers', new PHPWord_Section(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetElements()
|
public function testGetElements()
|
||||||
{
|
{
|
||||||
$oSection = new PHPWord_Section(0);
|
$oSection = new PHPWord_Section(0);
|
||||||
$this->assertAttributeEquals($oSection->getElements(), '_elementCollection',new PHPWord_Section(0));
|
$this->assertAttributeEquals($oSection->getElements(), '_elementCollection', new PHPWord_Section(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,19 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
namespace PHPWord\Tests;
|
namespace PHPWord\Tests\Shared;
|
||||||
|
|
||||||
use PHPUnit_Framework_TestCase;
|
use PHPUnit_Framework_TestCase;
|
||||||
use PHPWord;
|
use PHPWord;
|
||||||
use PHPWord_Shared_Font;
|
use PHPWord_Shared_Font;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PHPWord_Writer_Shared_FontTest
|
* Class FontTest
|
||||||
*
|
*
|
||||||
* @package PHPWord\Tests
|
* @package PHPWord\Tests
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class PHPWord_Writer_Shared_FontTest extends \PHPUnit_Framework_TestCase
|
class FontTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test various conversions
|
* Test various conversions
|
||||||
*/
|
*/
|
||||||
|
|
@ -44,5 +43,4 @@ class PHPWord_Writer_Shared_FontTest extends \PHPUnit_Framework_TestCase
|
||||||
$result = PHPWord_Shared_Font::pointSizeToTwips($original);
|
$result = PHPWord_Shared_Font::pointSizeToTwips($original);
|
||||||
$this->assertEquals($original * 20, $result);
|
$this->assertEquals($original * 20, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
namespace PHPWord\Tests;
|
namespace PHPWord\Tests\Style;
|
||||||
|
|
||||||
use PHPUnit_Framework_TestCase;
|
use PHPUnit_Framework_TestCase;
|
||||||
use PHPWord_Style_Cell;
|
use PHPWord_Style_Cell;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PHPWord_Style_CellTest
|
* Class CellTest
|
||||||
*
|
*
|
||||||
* @package PHPWord\Tests
|
* @package PHPWord\Tests
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class PHPWord_Style_CellTest extends \PHPUnit_Framework_TestCase
|
class CellTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test setting style with normal value
|
* Test setting style with normal value
|
||||||
*/
|
*/
|
||||||
|
|
@ -76,5 +75,4 @@ class PHPWord_Style_CellTest extends \PHPUnit_Framework_TestCase
|
||||||
$object->setStyleValue('_borderSize', $value);
|
$object->setStyleValue('_borderSize', $value);
|
||||||
$this->assertEquals($expected, $object->getBorderSize());
|
$this->assertEquals($expected, $object->getBorderSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,19 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
namespace PHPWord\Tests;
|
namespace PHPWord\Tests\Style;
|
||||||
|
|
||||||
use PHPUnit_Framework_TestCase;
|
use PHPUnit_Framework_TestCase;
|
||||||
use PHPWord;
|
use PHPWord;
|
||||||
use PHPWord_Style_Font;
|
use PHPWord_Style_Font;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PHPWord_Style_FontTest
|
* Class FontTest
|
||||||
*
|
*
|
||||||
* @package PHPWord\Tests
|
* @package PHPWord\Tests
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class PHPWord_Style_FontTest extends \PHPUnit_Framework_TestCase
|
class FontTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test initiation for style type and paragraph style
|
* Test initiation for style type and paragraph style
|
||||||
*/
|
*/
|
||||||
|
|
@ -78,5 +77,4 @@ class PHPWord_Style_FontTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals($value, $object->$get());
|
$this->assertEquals($value, $object->$get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
namespace PHPWord\Tests;
|
namespace PHPWord\Tests\Style;
|
||||||
|
|
||||||
use PHPUnit_Framework_TestCase;
|
use PHPUnit_Framework_TestCase;
|
||||||
|
use PHPWord;
|
||||||
use PHPWord_Style_Paragraph;
|
use PHPWord_Style_Paragraph;
|
||||||
use PHPWord_Style_Tab;
|
use PHPWord_Style_Tab;
|
||||||
|
use PHPWord\Tests\TestHelperDOCX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PHPWord_Style_ParagraphTest
|
* Class ParagraphTest
|
||||||
*
|
*
|
||||||
* @package PHPWord\Tests
|
* @package PHPWord\Tests
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class PHPWord_Style_ParagraphTest extends \PHPUnit_Framework_TestCase
|
class ParagraphTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
TestHelperDOCX::clear();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test setting style values with null or empty value
|
* Test setting style values with null or empty value
|
||||||
|
|
@ -87,4 +93,34 @@ class PHPWord_Style_ParagraphTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertInstanceOf('PHPWord_Style_Tabs', $object->getTabs());
|
$this->assertInstanceOf('PHPWord_Style_Tabs', $object->getTabs());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLineHeight()
|
||||||
|
{
|
||||||
|
$PHPWord = new PHPWord();
|
||||||
|
$section = $PHPWord->createSection();
|
||||||
|
|
||||||
|
// Test style array
|
||||||
|
$text = $section->addText('This is a test', array(), array(
|
||||||
|
'line-height' => 2.0
|
||||||
|
));
|
||||||
|
|
||||||
|
$doc = TestHelperDOCX::getDocument($PHPWord);
|
||||||
|
$element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:spacing');
|
||||||
|
|
||||||
|
$lineHeight = $element->getAttribute('w:line');
|
||||||
|
$lineRule = $element->getAttribute('w:lineRule');
|
||||||
|
|
||||||
|
$this->assertEquals(480, $lineHeight);
|
||||||
|
$this->assertEquals('auto', $lineRule);
|
||||||
|
|
||||||
|
// Test setter
|
||||||
|
$text->getParagraphStyle()->setLineHeight(3.0);
|
||||||
|
$doc = TestHelperDOCX::getDocument($PHPWord);
|
||||||
|
$element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:spacing');
|
||||||
|
|
||||||
|
$lineHeight = $element->getAttribute('w:line');
|
||||||
|
$lineRule = $element->getAttribute('w:lineRule');
|
||||||
|
|
||||||
|
$this->assertEquals(720, $lineHeight);
|
||||||
|
$this->assertEquals('auto', $lineRule);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,7 +6,7 @@ use PHPWord_Template;
|
||||||
/**
|
/**
|
||||||
* @coversDefaultClass PHPWord_Template
|
* @coversDefaultClass PHPWord_Template
|
||||||
*/
|
*/
|
||||||
class PHPWord_TemplateTest extends \PHPUnit_Framework_TestCase
|
class TemplateTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @covers ::applyXslStyleSheet
|
* @covers ::applyXslStyleSheet
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
namespace PHPWord\Tests;
|
namespace PHPWord\Tests\Writer\Word2007;
|
||||||
|
|
||||||
use PHPUnit_Framework_TestCase;
|
use PHPUnit_Framework_TestCase;
|
||||||
use PHPWord;
|
use PHPWord;
|
||||||
use PHPWord_Writer_Word2007;
|
use PHPWord\Tests\TestHelperDOCX;
|
||||||
use PHPWord_Writer_Word2007_Base;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PHPWord_Writer_Word2007_BaseTest
|
* Class BaseTest
|
||||||
* @package PHPWord\Tests
|
* @package PHPWord\Tests
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class PHPWord_Writer_Word2007_BaseTest extends \PHPUnit_Framework_TestCase {
|
class BaseTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Executed before each method of the class
|
* Executed before each method of the class
|
||||||
*/
|
*/
|
||||||
|
|
@ -108,5 +108,4 @@ class PHPWord_Writer_Word2007_BaseTest extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals($expected, $element->getAttribute('w:val'));
|
$this->assertEquals($expected, $element->getAttribute('w:val'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
namespace PHPWord\Tests;
|
namespace PHPWord\Tests\Writer\Word2007;
|
||||||
|
|
||||||
use PHPUnit_Framework_TestCase;
|
use PHPUnit_Framework_TestCase;
|
||||||
use PHPWord;
|
use PHPWord;
|
||||||
use PHPWord_Writer_Word2007;
|
use PHPWord_Writer_Word2007;
|
||||||
use PHPWord_Writer_Word2007_Document;
|
use PHPWord_Writer_Word2007_Document;
|
||||||
|
use PHPWord\Tests\TestHelperDOCX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PHPWord_Writer_Word2007_DocumentTest
|
* Class DocumentTest
|
||||||
* @package PHPWord\Tests
|
* @package PHPWord\Tests
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class PHPWord_Writer_Word2007_DocumentTest extends \PHPUnit_Framework_TestCase {
|
class DocumentTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Executed before each method of the class
|
* Executed before each method of the class
|
||||||
*/
|
*/
|
||||||
|
|
@ -32,4 +34,3 @@ class PHPWord_Writer_Word2007_DocumentTest extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals(2, $element->getAttribute('w:start'));
|
$this->assertEquals(2, $element->getAttribute('w:start'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
namespace PHPWord\Tests;
|
namespace PHPWord\Tests\Writer\Word2007;
|
||||||
|
|
||||||
use PHPUnit_Framework_TestCase;
|
use PHPUnit_Framework_TestCase;
|
||||||
use PHPWord;
|
use PHPWord;
|
||||||
use PHPWord_Writer_Word2007_Styles;
|
use PHPWord\Tests\TestHelperDOCX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PHPWord_Writer_Word2007_StylesTest
|
* Class PHPWord_Writer_Word2007_StylesTest
|
||||||
* @package PHPWord\Tests
|
* @package PHPWord\Tests
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class PHPWord_Writer_Word2007_StylesTest extends \PHPUnit_Framework_TestCase
|
class StylesTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Executed before each method of the class
|
* Executed before each method of the class
|
||||||
|
|
@ -51,5 +51,4 @@ class PHPWord_Writer_Word2007_StylesTest extends \PHPUnit_Framework_TestCase
|
||||||
$element = $doc->getElement($path, $file);
|
$element = $doc->getElement($path, $file);
|
||||||
$this->assertEquals('Normal', $element->getAttribute('w:val'));
|
$this->assertEquals('Normal', $element->getAttribute('w:val'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,7 @@ class TestHelperDOCX
|
||||||
$zip = new \ZipArchive;
|
$zip = new \ZipArchive;
|
||||||
$res = $zip->open(self::$file);
|
$res = $zip->open(self::$file);
|
||||||
if ($res === true) {
|
if ($res === true) {
|
||||||
$zip->extractTo(sys_get_temp_dir().'/PHPWord_Unit_Test/');
|
$zip->extractTo(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
|
||||||
$zip->close();
|
$zip->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
|
|
||||||
// Constantes
|
// Constantes
|
||||||
if(!defined('PHPWORD_TESTS_DIR_ROOT')){
|
if (!defined('PHPWORD_TESTS_DIR_ROOT')) {
|
||||||
define('PHPWORD_TESTS_DIR_ROOT', __DIR__);
|
define('PHPWORD_TESTS_DIR_ROOT', __DIR__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ Changes in branch for release 0.7.1 :
|
||||||
- Bugfix: (Progi1984) GH-89 - Example in README.md is broken
|
- Bugfix: (Progi1984) GH-89 - Example in README.md is broken
|
||||||
- Feature: (RomanSyroeshko) GH-56 GH-57 - Template : Permit to save a template generated as a file (PHPWord_Template::saveAs())
|
- Feature: (RomanSyroeshko) GH-56 GH-57 - Template : Permit to save a template generated as a file (PHPWord_Template::saveAs())
|
||||||
- Feature: (gabrielbull) - Word2007 : Support sections page numbering
|
- Feature: (gabrielbull) - Word2007 : Support sections page numbering
|
||||||
- Feature: (gabrielbull) - Word2007 : Added support for line height
|
- Feature: (gabrielbull) - Word2007 : Added line height methods to mirror the line height settings in Word in the paragraph styling
|
||||||
- Feature: (JillElaine) GH-5 - Word2007 : Added support for page header & page footer height
|
- Feature: (JillElaine) GH-5 - Word2007 : Added support for page header & page footer height
|
||||||
- Feature: (bskrtich) GH-6 GH-66 GH-84 - General : Add ability to manage line breaks after image insertion
|
- Feature: (bskrtich) GH-6 GH-66 GH-84 - General : Add ability to manage line breaks after image insertion
|
||||||
- Feature: (RomanSyroeshko) GH-52 GH-53 GH-85 - Template : Ability to limit number of replacements performed by setValue() method of Template class
|
- Feature: (RomanSyroeshko) GH-52 GH-53 GH-85 - Template : Ability to limit number of replacements performed by setValue() method of Template class
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue