Reformatted Tests to PSR-2 coding standards
This commit is contained in:
parent
63a535bf1a
commit
7abd5be62b
@ -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';
|
||||||
@ -153,8 +152,8 @@ class PHPWord_Style_Font
|
|||||||
/**
|
/**
|
||||||
* New font style
|
* New font style
|
||||||
*
|
*
|
||||||
* @param string $type Type of font
|
* @param string $type Type of font
|
||||||
* @param array $styleParagraph Paragraph styles definition
|
* @param array $styleParagraph Paragraph styles definition
|
||||||
*/
|
*/
|
||||||
public function __construct($type = 'text', $styleParagraph = null)
|
public function __construct($type = 'text', $styleParagraph = null)
|
||||||
{
|
{
|
||||||
@ -187,8 +186,8 @@ class PHPWord_Style_Font
|
|||||||
/**
|
/**
|
||||||
* Set style value
|
* Set style value
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
*/
|
*/
|
||||||
public function setStyleValue($key, $value)
|
public function setStyleValue($key, $value)
|
||||||
{
|
{
|
||||||
@ -211,7 +210,7 @@ class PHPWord_Style_Font
|
|||||||
/**
|
/**
|
||||||
* Set font name
|
* Set font name
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPWord_Style_Font
|
* @return PHPWord_Style_Font
|
||||||
*/
|
*/
|
||||||
public function setName($pValue = PHPWord::DEFAULT_FONT_NAME)
|
public function setName($pValue = PHPWord::DEFAULT_FONT_NAME)
|
||||||
@ -236,7 +235,7 @@ class PHPWord_Style_Font
|
|||||||
/**
|
/**
|
||||||
* Set font size
|
* Set font size
|
||||||
*
|
*
|
||||||
* @param int|float $pValue
|
* @param int|float $pValue
|
||||||
* @return PHPWord_Style_Font
|
* @return PHPWord_Style_Font
|
||||||
*/
|
*/
|
||||||
public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE)
|
public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE)
|
||||||
@ -261,7 +260,7 @@ class PHPWord_Style_Font
|
|||||||
/**
|
/**
|
||||||
* Set bold
|
* Set bold
|
||||||
*
|
*
|
||||||
* @param bool $pValue
|
* @param bool $pValue
|
||||||
* @return PHPWord_Style_Font
|
* @return PHPWord_Style_Font
|
||||||
*/
|
*/
|
||||||
public function setBold($pValue = false)
|
public function setBold($pValue = false)
|
||||||
@ -286,7 +285,7 @@ class PHPWord_Style_Font
|
|||||||
/**
|
/**
|
||||||
* Set italics
|
* Set italics
|
||||||
*
|
*
|
||||||
* @param bool $pValue
|
* @param bool $pValue
|
||||||
* @return PHPWord_Style_Font
|
* @return PHPWord_Style_Font
|
||||||
*/
|
*/
|
||||||
public function setItalic($pValue = false)
|
public function setItalic($pValue = false)
|
||||||
@ -311,7 +310,7 @@ class PHPWord_Style_Font
|
|||||||
/**
|
/**
|
||||||
* Set superscript
|
* Set superscript
|
||||||
*
|
*
|
||||||
* @param bool $pValue
|
* @param bool $pValue
|
||||||
* @return PHPWord_Style_Font
|
* @return PHPWord_Style_Font
|
||||||
*/
|
*/
|
||||||
public function setSuperScript($pValue = false)
|
public function setSuperScript($pValue = false)
|
||||||
@ -337,7 +336,7 @@ class PHPWord_Style_Font
|
|||||||
/**
|
/**
|
||||||
* Set subscript
|
* Set subscript
|
||||||
*
|
*
|
||||||
* @param bool $pValue
|
* @param bool $pValue
|
||||||
* @return PHPWord_Style_Font
|
* @return PHPWord_Style_Font
|
||||||
*/
|
*/
|
||||||
public function setSubScript($pValue = false)
|
public function setSubScript($pValue = false)
|
||||||
@ -363,7 +362,7 @@ class PHPWord_Style_Font
|
|||||||
/**
|
/**
|
||||||
* Set underline
|
* Set underline
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPWord_Style_Font
|
* @return PHPWord_Style_Font
|
||||||
*/
|
*/
|
||||||
public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE)
|
public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE)
|
||||||
@ -388,7 +387,7 @@ class PHPWord_Style_Font
|
|||||||
/**
|
/**
|
||||||
* Set strikethrough
|
* Set strikethrough
|
||||||
*
|
*
|
||||||
* @param bool $pValue
|
* @param bool $pValue
|
||||||
* @return PHPWord_Style_Font
|
* @return PHPWord_Style_Font
|
||||||
*/
|
*/
|
||||||
public function setStrikethrough($pValue = false)
|
public function setStrikethrough($pValue = false)
|
||||||
@ -413,7 +412,7 @@ class PHPWord_Style_Font
|
|||||||
/**
|
/**
|
||||||
* Set font color
|
* Set font color
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPWord_Style_Font
|
* @return PHPWord_Style_Font
|
||||||
*/
|
*/
|
||||||
public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR)
|
public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR)
|
||||||
@ -438,7 +437,7 @@ class PHPWord_Style_Font
|
|||||||
/**
|
/**
|
||||||
* Set foreground/highlight color
|
* Set foreground/highlight color
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPWord_Style_Font
|
* @return PHPWord_Style_Font
|
||||||
*/
|
*/
|
||||||
public function setFgColor($pValue = null)
|
public function setFgColor($pValue = null)
|
||||||
|
|||||||
@ -145,8 +145,8 @@ class PHPWord_Style_Paragraph
|
|||||||
/**
|
/**
|
||||||
* Set Style value
|
* Set Style value
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
*/
|
*/
|
||||||
public function setStyleValue($key, $value)
|
public function setStyleValue($key, $value)
|
||||||
{
|
{
|
||||||
@ -335,7 +335,7 @@ class PHPWord_Style_Paragraph
|
|||||||
/**
|
/**
|
||||||
* Set parent style ID
|
* Set parent style ID
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPWord_Style_Paragraph
|
* @return PHPWord_Style_Paragraph
|
||||||
*/
|
*/
|
||||||
public function setBasedOn($pValue = 'Normal')
|
public function setBasedOn($pValue = 'Normal')
|
||||||
@ -357,7 +357,7 @@ class PHPWord_Style_Paragraph
|
|||||||
/**
|
/**
|
||||||
* Set style for next paragraph
|
* Set style for next paragraph
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPWord_Style_Paragraph
|
* @return PHPWord_Style_Paragraph
|
||||||
*/
|
*/
|
||||||
public function setNext($pValue = null)
|
public function setNext($pValue = null)
|
||||||
@ -379,7 +379,7 @@ class PHPWord_Style_Paragraph
|
|||||||
/**
|
/**
|
||||||
* Set keep paragraph with next paragraph setting
|
* Set keep paragraph with next paragraph setting
|
||||||
*
|
*
|
||||||
* @param bool $pValue
|
* @param bool $pValue
|
||||||
* @return PHPWord_Style_Paragraph
|
* @return PHPWord_Style_Paragraph
|
||||||
*/
|
*/
|
||||||
public function setWidowControl($pValue = true)
|
public function setWidowControl($pValue = true)
|
||||||
@ -404,7 +404,7 @@ class PHPWord_Style_Paragraph
|
|||||||
/**
|
/**
|
||||||
* Set keep paragraph with next paragraph setting
|
* Set keep paragraph with next paragraph setting
|
||||||
*
|
*
|
||||||
* @param bool $pValue
|
* @param bool $pValue
|
||||||
* @return PHPWord_Style_Paragraph
|
* @return PHPWord_Style_Paragraph
|
||||||
*/
|
*/
|
||||||
public function setKeepNext($pValue = false)
|
public function setKeepNext($pValue = false)
|
||||||
@ -429,7 +429,7 @@ class PHPWord_Style_Paragraph
|
|||||||
/**
|
/**
|
||||||
* Set keep all lines on one page setting
|
* Set keep all lines on one page setting
|
||||||
*
|
*
|
||||||
* @param bool $pValue
|
* @param bool $pValue
|
||||||
* @return PHPWord_Style_Paragraph
|
* @return PHPWord_Style_Paragraph
|
||||||
*/
|
*/
|
||||||
public function setKeepLines($pValue = false)
|
public function setKeepLines($pValue = false)
|
||||||
@ -454,7 +454,7 @@ class PHPWord_Style_Paragraph
|
|||||||
/**
|
/**
|
||||||
* Set start paragraph on next page setting
|
* Set start paragraph on next page setting
|
||||||
*
|
*
|
||||||
* @param bool $pValue
|
* @param bool $pValue
|
||||||
* @return PHPWord_Style_Paragraph
|
* @return PHPWord_Style_Paragraph
|
||||||
*/
|
*/
|
||||||
public function setPageBreakBefore($pValue = false)
|
public function setPageBreakBefore($pValue = false)
|
||||||
|
|||||||
@ -11,49 +11,51 @@ use PHPWord_Writer_Word2007;
|
|||||||
* @package PHPWord\Tests
|
* @package PHPWord\Tests
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class PHPWord_IOFactoryTest extends \PHPUnit_Framework_TestCase {
|
class PHPWord_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');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Exception
|
* @expectedException Exception
|
||||||
* @expectedExceptionMessage Invalid parameter passed.
|
* @expectedExceptionMessage Invalid parameter passed.
|
||||||
*/
|
*/
|
||||||
public function testSetSearchLocationsWithNotArray()
|
public function testSetSearchLocationsWithNotArray()
|
||||||
{
|
{
|
||||||
PHPWord_IOFactory::setSearchLocations('String');
|
PHPWord_IOFactory::setSearchLocations('String');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddSearchLocation()
|
public function testAddSearchLocation()
|
||||||
{
|
{
|
||||||
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,26 +4,25 @@ 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 PHPWord_MediaTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testGetSectionMediaElementsWithNull()
|
||||||
|
{
|
||||||
|
$this->assertEquals(PHPWord_Media::getSectionMediaElements(), array());
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetSectionMediaElementsWithNull()
|
public function testCountSectionMediaElementsWithNull()
|
||||||
{
|
{
|
||||||
$this->assertEquals(PHPWord_Media::getSectionMediaElements(), array());
|
$this->assertEquals(PHPWord_Media::countSectionMediaElements(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCountSectionMediaElementsWithNull()
|
public function testGetHeaderMediaElements()
|
||||||
{
|
{
|
||||||
$this->assertEquals(PHPWord_Media::countSectionMediaElements(), 0);
|
$this->assertAttributeEquals(PHPWord_Media::getHeaderMediaElements(), '_headerMedia', 'PHPWord_Media');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetHeaderMediaElements()
|
public function testGetFooterMediaElements()
|
||||||
{
|
{
|
||||||
$this->assertAttributeEquals(PHPWord_Media::getHeaderMediaElements(), '_headerMedia','PHPWord_Media');
|
$this->assertAttributeEquals(PHPWord_Media::getFooterMediaElements(), '_footerMedia', 'PHPWord_Media');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public function testGetFooterMediaElements()
|
|
||||||
{
|
|
||||||
$this->assertAttributeEquals(PHPWord_Media::getFooterMediaElements(), '_footerMedia','PHPWord_Media');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -4,35 +4,35 @@ 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 PHPWord_SectionTest extends \PHPUnit_Framework_TestCase
|
||||||
public function testGetSettings()
|
{
|
||||||
{
|
public function testGetSettings()
|
||||||
$oSection = new PHPWord_Section(0);
|
{
|
||||||
$this->assertAttributeEquals($oSection->getSettings(), '_settings', new PHPWord_Section(0));
|
$oSection = new PHPWord_Section(0);
|
||||||
}
|
$this->assertAttributeEquals($oSection->getSettings(), '_settings', new PHPWord_Section(0));
|
||||||
|
}
|
||||||
|
|
||||||
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,7 +13,6 @@ use PHPWord_Shared_Font;
|
|||||||
*/
|
*/
|
||||||
class PHPWord_Writer_Shared_FontTest extends \PHPUnit_Framework_TestCase
|
class PHPWord_Writer_Shared_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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@ -12,7 +12,6 @@ use PHPWord_Style_Cell;
|
|||||||
*/
|
*/
|
||||||
class PHPWord_Style_CellTest extends \PHPUnit_Framework_TestCase
|
class PHPWord_Style_CellTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test setting style with normal value
|
* Test setting style with normal value
|
||||||
*/
|
*/
|
||||||
@ -35,7 +34,7 @@ class PHPWord_Style_CellTest extends \PHPUnit_Framework_TestCase
|
|||||||
'gridSpan' => 2,
|
'gridSpan' => 2,
|
||||||
'vMerge' => 2,
|
'vMerge' => 2,
|
||||||
);
|
);
|
||||||
//'defaultBorderColor' => null,
|
//'defaultBorderColor' => null,
|
||||||
foreach ($attributes as $key => $value) {
|
foreach ($attributes as $key => $value) {
|
||||||
$set = "set{$key}";
|
$set = "set{$key}";
|
||||||
$get = "get{$key}";
|
$get = "get{$key}";
|
||||||
@ -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());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@ -13,7 +13,6 @@ use PHPWord_Style_Font;
|
|||||||
*/
|
*/
|
||||||
class PHPWord_Style_FontTest extends \PHPUnit_Framework_TestCase
|
class PHPWord_Style_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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@ -13,7 +13,6 @@ use PHPWord_Style_Tab;
|
|||||||
*/
|
*/
|
||||||
class PHPWord_Style_ParagraphTest extends \PHPUnit_Framework_TestCase
|
class PHPWord_Style_ParagraphTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test setting style values with null or empty value
|
* Test setting style values with null or empty value
|
||||||
*/
|
*/
|
||||||
@ -86,5 +85,4 @@ class PHPWord_Style_ParagraphTest extends \PHPUnit_Framework_TestCase
|
|||||||
));
|
));
|
||||||
$this->assertInstanceOf('PHPWord_Style_Tabs', $object->getTabs());
|
$this->assertInstanceOf('PHPWord_Style_Tabs', $object->getTabs());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@ -20,7 +20,7 @@ class PHPWord_TemplateTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'with_table_macros.docx')
|
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'with_table_macros.docx')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$xslDOMDocument = new \DOMDocument();
|
$xslDOMDocument = new \DOMDocument();
|
||||||
$xslDOMDocument->load(
|
$xslDOMDocument->load(
|
||||||
\join(
|
\join(
|
||||||
@ -28,31 +28,31 @@ class PHPWord_TemplateTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'remove_tables_by_needle.xsl')
|
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'remove_tables_by_needle.xsl')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach (array('${employee.', '${scoreboard.') as $needle) {
|
foreach (array('${employee.', '${scoreboard.') as $needle) {
|
||||||
$template->applyXslStyleSheet($xslDOMDocument, array('needle' => $needle));
|
$template->applyXslStyleSheet($xslDOMDocument, array('needle' => $needle));
|
||||||
}
|
}
|
||||||
|
|
||||||
$actualDocument = $template->save();
|
$actualDocument = $template->save();
|
||||||
$expectedDocument = \join(
|
$expectedDocument = \join(
|
||||||
\DIRECTORY_SEPARATOR,
|
\DIRECTORY_SEPARATOR,
|
||||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'without_table_macros.docx')
|
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'without_table_macros.docx')
|
||||||
);
|
);
|
||||||
|
|
||||||
$actualZip = new \ZipArchive();
|
$actualZip = new \ZipArchive();
|
||||||
$actualZip->open($actualDocument);
|
$actualZip->open($actualDocument);
|
||||||
$actualXml = $actualZip->getFromName('word/document.xml');
|
$actualXml = $actualZip->getFromName('word/document.xml');
|
||||||
if ($actualZip->close() === false) {
|
if ($actualZip->close() === false) {
|
||||||
throw new \Exception('Could not close zip file "' . $actualDocument . '".');
|
throw new \Exception('Could not close zip file "' . $actualDocument . '".');
|
||||||
}
|
}
|
||||||
|
|
||||||
$expectedZip = new \ZipArchive();
|
$expectedZip = new \ZipArchive();
|
||||||
$expectedZip->open($expectedDocument);
|
$expectedZip->open($expectedDocument);
|
||||||
$expectedXml = $expectedZip->getFromName('word/document.xml');
|
$expectedXml = $expectedZip->getFromName('word/document.xml');
|
||||||
if ($expectedZip->close() === false) {
|
if ($expectedZip->close() === false) {
|
||||||
throw new \Exception('Could not close zip file "' . $expectedDocument . '".');
|
throw new \Exception('Could not close zip file "' . $expectedDocument . '".');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
|
$this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,52 +11,53 @@ use PHPWord_Writer_Word2007_Base;
|
|||||||
* @package PHPWord\Tests
|
* @package PHPWord\Tests
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class PHPWord_Writer_Word2007_BaseTest extends \PHPUnit_Framework_TestCase {
|
class PHPWord_Writer_Word2007_BaseTest extends \PHPUnit_Framework_TestCase
|
||||||
/**
|
{
|
||||||
* Executed before each method of the class
|
/**
|
||||||
*/
|
* Executed before each method of the class
|
||||||
public function tearDown()
|
*/
|
||||||
{
|
public function tearDown()
|
||||||
TestHelperDOCX::clear();
|
{
|
||||||
}
|
TestHelperDOCX::clear();
|
||||||
|
}
|
||||||
|
|
||||||
public function testWriteImage_Position()
|
public function testWriteImage_Position()
|
||||||
{
|
{
|
||||||
$PHPWord = new PHPWord();
|
$PHPWord = new PHPWord();
|
||||||
$section = $PHPWord->createSection();
|
$section = $PHPWord->createSection();
|
||||||
$section->addImage(
|
$section->addImage(
|
||||||
PHPWORD_TESTS_DIR_ROOT . '/_files/images/earth.jpg',
|
PHPWORD_TESTS_DIR_ROOT . '/_files/images/earth.jpg',
|
||||||
array(
|
array(
|
||||||
'marginTop' => -1,
|
'marginTop' => -1,
|
||||||
'marginLeft' => -1,
|
'marginLeft' => -1,
|
||||||
'wrappingStyle' => 'behind'
|
'wrappingStyle' => 'behind'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$doc = TestHelperDOCX::getDocument($PHPWord);
|
$doc = TestHelperDOCX::getDocument($PHPWord);
|
||||||
$element = $doc->getElement('/w:document/w:body/w:p/w:r/w:pict/v:shape');
|
$element = $doc->getElement('/w:document/w:body/w:p/w:r/w:pict/v:shape');
|
||||||
|
|
||||||
$style = $element->getAttribute('style');
|
$style = $element->getAttribute('style');
|
||||||
|
|
||||||
$this->assertRegExp('/z\-index:\-[0-9]*/', $style);
|
$this->assertRegExp('/z\-index:\-[0-9]*/', $style);
|
||||||
$this->assertRegExp('/position:absolute;/', $style);
|
$this->assertRegExp('/position:absolute;/', $style);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWriteParagraphStyle_Align()
|
public function testWriteParagraphStyle_Align()
|
||||||
{
|
{
|
||||||
$PHPWord = new PHPWord();
|
$PHPWord = new PHPWord();
|
||||||
$section = $PHPWord->createSection();
|
$section = $PHPWord->createSection();
|
||||||
|
|
||||||
$section->addText('This is my text', null, array('align' => 'right'));
|
$section->addText('This is my text', null, array('align' => 'right'));
|
||||||
|
|
||||||
$doc = TestHelperDOCX::getDocument($PHPWord);
|
$doc = TestHelperDOCX::getDocument($PHPWord);
|
||||||
$element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:jc');
|
$element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:jc');
|
||||||
|
|
||||||
$this->assertEquals('right', $element->getAttribute('w:val'));
|
$this->assertEquals('right', $element->getAttribute('w:val'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWriteCellStyle_CellGridSpan()
|
public function testWriteCellStyle_CellGridSpan()
|
||||||
{
|
{
|
||||||
$PHPWord = new PHPWord();
|
$PHPWord = new PHPWord();
|
||||||
$section = $PHPWord->createSection();
|
$section = $PHPWord->createSection();
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ class PHPWord_Writer_Word2007_BaseTest extends \PHPUnit_Framework_TestCase {
|
|||||||
$element = $doc->getElement('/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:gridSpan');
|
$element = $doc->getElement('/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:gridSpan');
|
||||||
|
|
||||||
$this->assertEquals(5, $element->getAttribute('w:val'));
|
$this->assertEquals(5, $element->getAttribute('w:val'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test write paragraph pagination
|
* Test write paragraph pagination
|
||||||
@ -108,5 +109,4 @@ class PHPWord_Writer_Word2007_BaseTest extends \PHPUnit_Framework_TestCase {
|
|||||||
$this->assertEquals($expected, $element->getAttribute('w:val'));
|
$this->assertEquals($expected, $element->getAttribute('w:val'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@ -11,25 +11,25 @@ use PHPWord_Writer_Word2007_Document;
|
|||||||
* @package PHPWord\Tests
|
* @package PHPWord\Tests
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class PHPWord_Writer_Word2007_DocumentTest extends \PHPUnit_Framework_TestCase {
|
class PHPWord_Writer_Word2007_DocumentTest extends \PHPUnit_Framework_TestCase
|
||||||
/**
|
{
|
||||||
* Executed before each method of the class
|
/**
|
||||||
*/
|
* Executed before each method of the class
|
||||||
public function tearDown()
|
*/
|
||||||
{
|
public function tearDown()
|
||||||
TestHelperDOCX::clear();
|
{
|
||||||
}
|
TestHelperDOCX::clear();
|
||||||
|
}
|
||||||
|
|
||||||
public function testWriteEndSection_PageNumbering()
|
public function testWriteEndSection_PageNumbering()
|
||||||
{
|
{
|
||||||
$PHPWord = new PHPWord();
|
$PHPWord = new PHPWord();
|
||||||
$section = $PHPWord->createSection();
|
$section = $PHPWord->createSection();
|
||||||
$section->getSettings()->setPageNumberingStart(2);
|
$section->getSettings()->setPageNumberingStart(2);
|
||||||
|
|
||||||
$doc = TestHelperDOCX::getDocument($PHPWord);
|
$doc = TestHelperDOCX::getDocument($PHPWord);
|
||||||
$element = $doc->getElement('/w:document/w:body/w:sectPr/w:pgNumType');
|
$element = $doc->getElement('/w:document/w:body/w:sectPr/w:pgNumType');
|
||||||
|
|
||||||
$this->assertEquals(2, $element->getAttribute('w:start'));
|
$this->assertEquals(2, $element->getAttribute('w:start'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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,8 +3,8 @@
|
|||||||
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__);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Includes
|
// Includes
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user