Reformatted tests to PSR-2 standards

This commit is contained in:
Gabriel Bull 2014-03-09 15:04:23 -04:00
parent 9966508a62
commit a6671c2f0f
18 changed files with 1157 additions and 1009 deletions

View File

@ -1,11 +1,13 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section\Footer;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_Footer_PreserveText;
class PHPWord_Section_Footer_PreserveTextTest extends \PHPUnit_Framework_TestCase {
public function testConstruct(){
class PreserveTextTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$oPreserveText = new PHPWord_Section_Footer_PreserveText();
$this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $oPreserveText);
@ -14,17 +16,18 @@ class PHPWord_Section_Footer_PreserveTextTest extends \PHPUnit_Framework_TestCas
$this->assertEquals($oPreserveText->getParagraphStyle(), null);
}
public function testConstructWithString(){
public function testConstructWithString()
{
$oPreserveText = new PHPWord_Section_Footer_PreserveText('text', 'styleFont', 'styleParagraph');
$this->assertEquals($oPreserveText->getText(), 'text');
$this->assertEquals($oPreserveText->getFontStyle(), 'styleFont');
$this->assertEquals($oPreserveText->getParagraphStyle(), 'styleParagraph');
}
public function testConstructWithArray(){
$oPreserveText = new PHPWord_Section_Footer_PreserveText('text', array('align'=>'center'), array('marginLeft'=>600, 'marginRight'=>600, 'marginTop'=>600, 'marginBottom'=>600));
public function testConstructWithArray()
{
$oPreserveText = new PHPWord_Section_Footer_PreserveText('text', array('align' => 'center'), array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600));
$this->assertInstanceOf('PHPWord_Style_Font', $oPreserveText->getFontStyle());
$this->assertInstanceOf('PHPWord_Style_Paragraph', $oPreserveText->getParagraphStyle());
}
}

View File

@ -1,12 +1,13 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_Footer;
class PHPWord_Section_FooterTest extends \PHPUnit_Framework_TestCase {
public function testConstruct(){
class FooterTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$iVal = rand(1, 1000);
$oFooter = new PHPWord_Section_Footer($iVal);
@ -14,7 +15,8 @@ class PHPWord_Section_FooterTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oFooter->getFooterCount(), $iVal);
}
public function testRelationID(){
public function testRelationID()
{
$oFooter = new PHPWord_Section_Footer(0);
$iVal = rand(1, 1000);
@ -22,7 +24,8 @@ class PHPWord_Section_FooterTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oFooter->getRelationId(), $iVal);
}
public function testAddText(){
public function testAddText()
{
$oFooter = new PHPWord_Section_Footer(1);
$element = $oFooter->addText('text');
@ -31,7 +34,8 @@ class PHPWord_Section_FooterTest extends \PHPUnit_Framework_TestCase {
}
public function testAddTextNotUTF8(){
public function testAddTextNotUTF8()
{
$oFooter = new PHPWord_Section_Footer(1);
$element = $oFooter->addText(utf8_decode('ééé'));
@ -40,7 +44,8 @@ class PHPWord_Section_FooterTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($element->getText(), 'ééé');
}
public function testAddTextBreak(){
public function testAddTextBreak()
{
$oFooter = new PHPWord_Section_Footer(1);
$iVal = rand(1, 1000);
$oFooter->addTextBreak($iVal);
@ -48,7 +53,8 @@ class PHPWord_Section_FooterTest extends \PHPUnit_Framework_TestCase {
$this->assertCount($iVal, $oFooter->getElements());
}
public function testCreateTextRun(){
public function testCreateTextRun()
{
$oFooter = new PHPWord_Section_Footer(1);
$element = $oFooter->createTextRun();
@ -56,7 +62,8 @@ class PHPWord_Section_FooterTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_TextRun', $element);
}
public function testAddTable(){
public function testAddTable()
{
$oFooter = new PHPWord_Section_Footer(1);
$element = $oFooter->addTable();
@ -64,7 +71,8 @@ class PHPWord_Section_FooterTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Table', $element);
}
public function testAddImage(){
public function testAddImage()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
@ -76,7 +84,8 @@ class PHPWord_Section_FooterTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Image', $element);
}
public function testAddMemoryImage(){
public function testAddMemoryImage()
{
$oFooter = new PHPWord_Section_Footer(1);
$element = $oFooter->addMemoryImage('https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png');
@ -84,7 +93,8 @@ class PHPWord_Section_FooterTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
}
public function testAddPreserveText(){
public function testAddPreserveText()
{
$oFooter = new PHPWord_Section_Footer(1);
$element = $oFooter->addPreserveText('text');
@ -92,7 +102,8 @@ class PHPWord_Section_FooterTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
}
public function testAddPreserveTextNotUTF8(){
public function testAddPreserveTextNotUTF8()
{
$oFooter = new PHPWord_Section_Footer(1);
$element = $oFooter->addPreserveText(utf8_decode('ééé'));
@ -101,10 +112,10 @@ class PHPWord_Section_FooterTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($element->getText(), 'ééé');
}
public function testGetElements(){
public function testGetElements()
{
$oFooter = new PHPWord_Section_Footer(1);
$this->assertInternalType('array', $oFooter->getElements());
}
}

View File

@ -1,12 +1,13 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_Footnote;
class PHPWord_Section_FootnoteTest extends \PHPUnit_Framework_TestCase {
public function testConstruct(){
class FootnoteTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$oFootnote = new PHPWord_Section_Footnote();
$this->assertInstanceOf('PHPWord_Section_Footnote', $oFootnote);
@ -14,19 +15,22 @@ class PHPWord_Section_FootnoteTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oFootnote->getParagraphStyle(), null);
}
public function testConstructString(){
public function testConstructString()
{
$oFootnote = new PHPWord_Section_Footnote('pStyle');
$this->assertEquals($oFootnote->getParagraphStyle(), 'pStyle');
}
public function testConstructArray(){
public function testConstructArray()
{
$oFootnote = new PHPWord_Section_Footnote(array('spacing' => 100));
$this->assertInstanceOf('PHPWord_Style_Paragraph', $oFootnote->getParagraphStyle());
}
public function testAddText(){
public function testAddText()
{
$oFootnote = new PHPWord_Section_Footnote();
$element = $oFootnote->addText('text');
@ -34,7 +38,8 @@ class PHPWord_Section_FootnoteTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Text', $element);
}
public function testAddLink(){
public function testAddLink()
{
$oFootnote = new PHPWord_Section_Footnote();
$element = $oFootnote->addLink('http://www.google.fr');
@ -42,7 +47,8 @@ class PHPWord_Section_FootnoteTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Link', $element);
}
public function testReferenceId(){
public function testReferenceId()
{
$oFootnote = new PHPWord_Section_Footnote();
$iVal = rand(1, 1000);
@ -50,9 +56,9 @@ class PHPWord_Section_FootnoteTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oFootnote->getReferenceId(), $iVal);
}
public function testGetElements(){
public function testGetElements()
{
$oFootnote = new PHPWord_Section_Footnote();
$this->assertInternalType('array', $oFootnote->getElements());
}
}

View File

@ -1,11 +1,13 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_Header;
class PHPWord_Section_HeaderTest extends \PHPUnit_Framework_TestCase {
public function testConstructDefault() {
class HeaderTest extends \PHPUnit_Framework_TestCase
{
public function testConstructDefault()
{
$iVal = rand(1, 1000);
$oHeader = new PHPWord_Section_Header($iVal);
@ -14,7 +16,8 @@ class PHPWord_Section_HeaderTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oHeader->getType(), PHPWord_Section_Header::AUTO);
}
public function testAddText(){
public function testAddText()
{
$oHeader = new PHPWord_Section_Header(1);
$element = $oHeader->addText('text');
@ -23,7 +26,8 @@ class PHPWord_Section_HeaderTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($element->getText(), 'text');
}
public function testAddTextNotUTF8(){
public function testAddTextNotUTF8()
{
$oHeader = new PHPWord_Section_Header(1);
$element = $oHeader->addText(utf8_decode('ééé'));
@ -32,34 +36,39 @@ class PHPWord_Section_HeaderTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($element->getText(), 'ééé');
}
public function testAddTextBreak(){
public function testAddTextBreak()
{
$oHeader = new PHPWord_Section_Header(1);
$oHeader->addTextBreak();
$this->assertCount(1, $oHeader->getElements());
}
public function testAddTextBreakWithParams(){
public function testAddTextBreakWithParams()
{
$oHeader = new PHPWord_Section_Header(1);
$iVal = rand(1, 1000);
$oHeader->addTextBreak($iVal);
$this->assertCount($iVal, $oHeader->getElements());
}
public function testCreateTextRun(){
public function testCreateTextRun()
{
$oHeader = new PHPWord_Section_Header(1);
$element = $oHeader->createTextRun();
$this->assertInstanceOf('PHPWord_Section_TextRun', $element);
$this->assertCount(1, $oHeader->getElements());
}
public function testAddTable(){
public function testAddTable()
{
$oHeader = new PHPWord_Section_Header(1);
$element = $oHeader->addTable();
$this->assertInstanceOf('PHPWord_Section_Table', $element);
$this->assertCount(1, $oHeader->getElements());
}
public function testAddImage(){
public function testAddImage()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
@ -71,7 +80,8 @@ class PHPWord_Section_HeaderTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Image', $element);
}
public function testAddMemoryImage(){
public function testAddMemoryImage()
{
$oHeader = new PHPWord_Section_Header(1);
$element = $oHeader->addMemoryImage('https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png');
@ -79,7 +89,8 @@ class PHPWord_Section_HeaderTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
}
public function testAddPreserveText(){
public function testAddPreserveText()
{
$oHeader = new PHPWord_Section_Header(1);
$element = $oHeader->addPreserveText('text');
@ -87,7 +98,8 @@ class PHPWord_Section_HeaderTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
}
public function testAddPreserveTextNotUTF8(){
public function testAddPreserveTextNotUTF8()
{
$oHeader = new PHPWord_Section_Header(1);
$element = $oHeader->addPreserveText(utf8_decode('ééé'));
@ -96,7 +108,8 @@ class PHPWord_Section_HeaderTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($element->getText(), 'ééé');
}
public function testAddWatermark(){
public function testAddWatermark()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
@ -108,13 +121,15 @@ class PHPWord_Section_HeaderTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Image', $element);
}
public function testGetElements(){
public function testGetElements()
{
$oHeader = new PHPWord_Section_Header(1);
$this->assertInternalType('array', $oHeader->getElements());
}
public function testRelationId(){
public function testRelationId()
{
$oHeader = new PHPWord_Section_Header(1);
$iVal = rand(1, 1000);
@ -122,7 +137,8 @@ class PHPWord_Section_HeaderTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oHeader->getRelationId(), $iVal);
}
public function testResetType(){
public function testResetType()
{
$oHeader = new PHPWord_Section_Header(1);
$oHeader->firstPage();
$oHeader->resetType();
@ -130,14 +146,16 @@ class PHPWord_Section_HeaderTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oHeader->getType(), PHPWord_Section_Header::AUTO);
}
public function testFirstPage(){
public function testFirstPage()
{
$oHeader = new PHPWord_Section_Header(1);
$oHeader->firstPage();
$this->assertEquals($oHeader->getType(), PHPWord_Section_Header::FIRST);
}
public function testEvenPage(){
public function testEvenPage()
{
$oHeader = new PHPWord_Section_Header(1);
$oHeader->evenPage();

View File

@ -1,12 +1,14 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_Image;
use PHPWord_Style_Image;
class PHPWord_Section_ImageTest extends \PHPUnit_Framework_TestCase {
public function testConstruct() {
class ImageTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'firefox.png')
@ -19,26 +21,30 @@ class PHPWord_Section_ImageTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oImage->getIsWatermark(), false);
$this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle());
}
public function testConstructWithStyle() {
public function testConstructWithStyle()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'firefox.png')
);
$oImage = new PHPWord_Section_Image($src, array('width'=>210, 'height'=>210, 'align'=>'center', 'wrappingStyle' => \PHPWord_Style_Image::WRAPPING_STYLE_BEHIND));
$oImage = new PHPWord_Section_Image($src, array('width' => 210, 'height' => 210, 'align' => 'center', 'wrappingStyle' => \PHPWord_Style_Image::WRAPPING_STYLE_BEHIND));
$this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle());
}
public function testStyle(){
public function testStyle()
{
$oImage = new PHPWord_Section_Image(\join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
), array('width'=>210, 'height'=>210, 'align'=>'center'));
), array('width' => 210, 'height' => 210, 'align' => 'center'));
$this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle());
}
public function testRelationID(){
public function testRelationID()
{
$oImage = new PHPWord_Section_Image(\join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
@ -49,7 +55,8 @@ class PHPWord_Section_ImageTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oImage->getRelationId(), $iVal);
}
public function testWatermark(){
public function testWatermark()
{
$oImage = new PHPWord_Section_Image(\join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
@ -59,4 +66,3 @@ class PHPWord_Section_ImageTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oImage->getIsWatermark(), true);
}
}

View File

@ -1,12 +1,14 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_Link;
use PHPWord_Style_Font;
class PHPWord_Section_LinkTest extends \PHPUnit_Framework_TestCase {
public function testConstructDefault() {
class LinkTest extends \PHPUnit_Framework_TestCase
{
public function testConstructDefault()
{
$oLink = new PHPWord_Section_Link('http://www.google.com');
$this->assertInstanceOf('PHPWord_Section_Link', $oLink);
@ -15,8 +17,10 @@ class PHPWord_Section_LinkTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oLink->getFontStyle(), null);
$this->assertEquals($oLink->getParagraphStyle(), null);
}
public function testConstructWithParamsArray() {
$oLink = new PHPWord_Section_Link('http://www.google.com', 'Search Engine', array('color'=>'0000FF', 'underline'=>PHPWord_Style_Font::UNDERLINE_SINGLE), array('marginLeft'=>600, 'marginRight'=>600, 'marginTop'=>600, 'marginBottom'=>600));
public function testConstructWithParamsArray()
{
$oLink = new PHPWord_Section_Link('http://www.google.com', 'Search Engine', array('color' => '0000FF', 'underline' => PHPWord_Style_Font::UNDERLINE_SINGLE), array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600));
$this->assertInstanceOf('PHPWord_Section_Link', $oLink);
$this->assertEquals($oLink->getLinkSrc(), 'http://www.google.com');
@ -24,14 +28,17 @@ class PHPWord_Section_LinkTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Style_Font', $oLink->getFontStyle());
$this->assertInstanceOf('PHPWord_Style_Paragraph', $oLink->getParagraphStyle());
}
public function testConstructWithParamsString() {
public function testConstructWithParamsString()
{
$oLink = new PHPWord_Section_Link('http://www.google.com', null, 'fontStyle', 'paragraphStyle');
$this->assertEquals($oLink->getFontStyle(), 'fontStyle');
$this->assertEquals($oLink->getParagraphStyle(), 'paragraphStyle');
}
public function testRelationId(){
public function testRelationId()
{
$oLink = new PHPWord_Section_Link('http://www.google.com');
$iVal = rand(1, 1000);
@ -39,4 +46,3 @@ class PHPWord_Section_LinkTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oLink->getRelationId(), $iVal);
}
}

View File

@ -1,29 +1,32 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_ListItem;
use PHPWord_Style_ListItem;
class PHPWord_Section_ListItemTest extends \PHPUnit_Framework_TestCase {
public function testText(){
class ListItemTest extends \PHPUnit_Framework_TestCase
{
public function testText()
{
$oListItem = new PHPWord_Section_ListItem('text');
$this->assertInstanceOf('PHPWord_Section_Text', $oListItem->getTextObject());
}
public function testStyle(){
$oListItem = new PHPWord_Section_ListItem('text', 1, null, array('listType'=>PHPWord_Style_ListItem::TYPE_NUMBER));
public function testStyle()
{
$oListItem = new PHPWord_Section_ListItem('text', 1, null, array('listType' => PHPWord_Style_ListItem::TYPE_NUMBER));
$this->assertInstanceOf('PHPWord_Style_ListItem', $oListItem->getStyle());
$this->assertEquals($oListItem->getStyle()->getListType(), PHPWord_Style_ListItem::TYPE_NUMBER);
}
public function testDepth(){
public function testDepth()
{
$iVal = rand(1, 1000);
$oListItem = new PHPWord_Section_ListItem('text', $iVal);
$this->assertEquals($oListItem->getDepth(), $iVal);
}
}

View File

@ -1,11 +1,13 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_MemoryImage;
class PHPWord_Section_MemoryImageTest extends \PHPUnit_Framework_TestCase {
public function testPNG() {
class MemoryImageTest extends \PHPUnit_Framework_TestCase
{
public function testPNG()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'firefox.png')
@ -21,7 +23,8 @@ class PHPWord_Section_MemoryImageTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oMemoryImage->getImageType(), 'image/png');
}
public function testGIF() {
public function testGIF()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'mario.gif')
@ -37,7 +40,8 @@ class PHPWord_Section_MemoryImageTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oMemoryImage->getImageType(), 'image/gif');
}
public function testJPG() {
public function testJPG()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
@ -53,7 +57,8 @@ class PHPWord_Section_MemoryImageTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oMemoryImage->getImageType(), 'image/jpeg');
}
public function testBMP() {
public function testBMP()
{
$oMemoryImage = new PHPWord_Section_MemoryImage(\join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'duke_nukem.bmp')
@ -66,16 +71,18 @@ class PHPWord_Section_MemoryImageTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oMemoryImage->getImageType(), 'image/x-ms-bmp');
}
public function testStyle(){
public function testStyle()
{
$oMemoryImage = new PHPWord_Section_MemoryImage(\join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
), array('width'=>210, 'height'=>210, 'align'=>'center'));
), array('width' => 210, 'height' => 210, 'align' => 'center'));
$this->assertInstanceOf('PHPWord_Style_Image', $oMemoryImage->getStyle());
}
public function testRelationID(){
public function testRelationID()
{
$oMemoryImage = new PHPWord_Section_MemoryImage(\join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
@ -86,4 +93,3 @@ class PHPWord_Section_MemoryImageTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oMemoryImage->getRelationId(), $iVal);
}
}

View File

@ -1,11 +1,13 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_Object;
class PHPWord_Section_ObjectTest extends \PHPUnit_Framework_TestCase {
public function testConstructWithSupportedFiles() {
class ObjectTest extends \PHPUnit_Framework_TestCase
{
public function testConstructWithSupportedFiles()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
@ -16,7 +18,9 @@ class PHPWord_Section_ObjectTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Style_Image', $oObject->getStyle());
$this->assertEquals($oObject->getSource(), $src);
}
public function testConstructWithNotSupportedFiles() {
public function testConstructWithNotSupportedFiles()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl')
@ -28,7 +32,8 @@ class PHPWord_Section_ObjectTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oObject->getStyle(), null);
}
public function testConstructWithSupportedFilesAndStyle() {
public function testConstructWithSupportedFilesAndStyle()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
@ -40,7 +45,8 @@ class PHPWord_Section_ObjectTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oObject->getSource(), $src);
}
public function testRelationId(){
public function testRelationId()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
@ -52,7 +58,8 @@ class PHPWord_Section_ObjectTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oObject->getRelationId(), $iVal);
}
public function testImageRelationId(){
public function testImageRelationId()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
@ -64,7 +71,8 @@ class PHPWord_Section_ObjectTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oObject->getImageRelationId(), $iVal);
}
public function testObjectId(){
public function testObjectId()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
@ -76,4 +84,3 @@ class PHPWord_Section_ObjectTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oObject->getObjectId(), $iVal);
}
}

View File

@ -1,18 +1,19 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_PageBreak;
class PHPWord_Section_PageBreakTest extends \PHPUnit_Framework_TestCase {
class PageBreakTest extends \PHPUnit_Framework_TestCase
{
/**
* Executed before each method of the class
*/
public function testConstruct() {
public function testConstruct()
{
// Section Settings
$oPageBreak = new PHPWord_Section_PageBreak();
$this->assertInstanceOf('PHPWord_Section_PageBreak', $oPageBreak);
}
}

View File

@ -1,14 +1,16 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_Settings;
class PHPWord_Section_SettingsTest extends \PHPUnit_Framework_TestCase {
class SettingsTest extends \PHPUnit_Framework_TestCase
{
/**
* Executed before each method of the class
*/
public function testSettingValue() {
public function testSettingValue()
{
// Section Settings
$oSettings = new PHPWord_Section_Settings();
@ -42,7 +44,8 @@ class PHPWord_Section_SettingsTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oSettings->getHeaderHeight(), $iVal);
}
public function testMargin(){
public function testMargin()
{
// Section Settings
$oSettings = new PHPWord_Section_Settings();
@ -63,7 +66,8 @@ class PHPWord_Section_SettingsTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oSettings->getMarginRight(), $iVal);
}
public function testOrientationLandscape(){
public function testOrientationLandscape()
{
// Section Settings
$oSettings = new PHPWord_Section_Settings();
@ -73,7 +77,8 @@ class PHPWord_Section_SettingsTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oSettings->getPageSizeH(), 11906);
}
public function testOrientationPortrait(){
public function testOrientationPortrait()
{
// Section Settings
$oSettings = new PHPWord_Section_Settings();
@ -83,7 +88,8 @@ class PHPWord_Section_SettingsTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oSettings->getPageSizeH(), 16838);
}
public function testBorderSize(){
public function testBorderSize()
{
// Section Settings
$oSettings = new PHPWord_Section_Settings();
@ -112,7 +118,8 @@ class PHPWord_Section_SettingsTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oSettings->getBorderTopSize(), $iVal);
}
public function testBorderColor(){
public function testBorderColor()
{
// Section Settings
$oSettings = new PHPWord_Section_Settings();
@ -136,7 +143,8 @@ class PHPWord_Section_SettingsTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oSettings->getBorderTopColor(), '22FF33');
}
public function testNumberingStart(){
public function testNumberingStart()
{
// Section Settings
$oSettings = new PHPWord_Section_Settings();
@ -150,7 +158,8 @@ class PHPWord_Section_SettingsTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oSettings->getPageNumberingStart(), null);
}
public function testHeader(){
public function testHeader()
{
// Section Settings
$oSettings = new PHPWord_Section_Settings();
@ -164,7 +173,8 @@ class PHPWord_Section_SettingsTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oSettings->getHeaderHeight(), 720);
}
public function testFooter(){
public function testFooter()
{
// Section Settings
$oSettings = new PHPWord_Section_Settings();
@ -178,7 +188,8 @@ class PHPWord_Section_SettingsTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oSettings->getFooterHeight(), 720);
}
public function testColumnsNum(){
public function testColumnsNum()
{
// Section Settings
$oSettings = new PHPWord_Section_Settings();
@ -193,7 +204,8 @@ class PHPWord_Section_SettingsTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oSettings->getColsNum(), 1);
}
public function testColumnsSpace(){
public function testColumnsSpace()
{
// Section Settings
$oSettings = new PHPWord_Section_Settings();
@ -208,7 +220,8 @@ class PHPWord_Section_SettingsTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oSettings->getColsSpace(), 1);
}
public function testBreakType(){
public function testBreakType()
{
// Section Settings
$oSettings = new PHPWord_Section_Settings();
@ -221,4 +234,3 @@ class PHPWord_Section_SettingsTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oSettings->getBreakType(), null);
}
}

View File

@ -1,11 +1,13 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section\Table;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_Table_Cell;
class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
public function testConstruct(){
class CellTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$iVal = rand(1, 1000);
$oCell = new PHPWord_Section_Table_Cell('section', $iVal);
@ -13,22 +15,25 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oCell->getWidth(), null);
}
public function testConstructWithStyleArray(){
public function testConstructWithStyleArray()
{
$iVal = rand(1, 1000);
$oCell = new PHPWord_Section_Table_Cell('section', $iVal, null, array('valign'=>'center'));
$oCell = new PHPWord_Section_Table_Cell('section', $iVal, null, array('valign' => 'center'));
$this->assertInstanceOf('PHPWord_Style_Cell', $oCell->getStyle());
$this->assertEquals($oCell->getWidth(), null);
}
public function testConstructWithStyleString(){
public function testConstructWithStyleString()
{
$iVal = rand(1, 1000);
$oCell = new PHPWord_Section_Table_Cell('section', $iVal, null, 'cellStyle');
$this->assertEquals($oCell->getStyle(), 'cellStyle');
}
public function testAddText(){
public function testAddText()
{
$oCell = new PHPWord_Section_Table_Cell('section', 1);
$element = $oCell->addText('text');
@ -36,7 +41,8 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Text', $element);
}
public function testAddTextNotUTF8(){
public function testAddTextNotUTF8()
{
$oCell = new PHPWord_Section_Table_Cell('section', 1);
$element = $oCell->addText(utf8_decode('ééé'));
@ -45,7 +51,8 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($element->getText(), 'ééé');
}
public function testAddLink(){
public function testAddLink()
{
$oCell = new PHPWord_Section_Table_Cell('section', 1);
$element = $oCell->addLink('http://www.google.fr', 'Nom');
@ -53,14 +60,16 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Link', $element);
}
public function testAddTextBreak(){
public function testAddTextBreak()
{
$oCell = new PHPWord_Section_Table_Cell('section', 1);
$oCell->addTextBreak();
$this->assertCount(1, $oCell->getElements());
}
public function testAddListItem(){
public function testAddListItem()
{
$oCell = new PHPWord_Section_Table_Cell('section', 1);
$element = $oCell->addListItem('text');
@ -69,7 +78,8 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($element->getTextObject()->getText(), 'text');
}
public function testAddListItemNotUTF8(){
public function testAddListItemNotUTF8()
{
$oCell = new PHPWord_Section_Table_Cell('section', 1);
$element = $oCell->addListItem(utf8_decode('ééé'));
@ -78,7 +88,8 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($element->getTextObject()->getText(), 'ééé');
}
public function testAddImageSection(){
public function testAddImageSection()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
@ -90,7 +101,8 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Image', $element);
}
public function testAddImageHeader(){
public function testAddImageHeader()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
@ -102,7 +114,8 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Image', $element);
}
public function testAddImageFooter(){
public function testAddImageFooter()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
@ -114,7 +127,8 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Image', $element);
}
public function testAddMemoryImageSection(){
public function testAddMemoryImageSection()
{
$oCell = new PHPWord_Section_Table_Cell('section', 1);
$element = $oCell->addMemoryImage('https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png');
@ -122,7 +136,8 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
}
public function testAddMemoryImageHeader(){
public function testAddMemoryImageHeader()
{
$oCell = new PHPWord_Section_Table_Cell('header', 1);
$element = $oCell->addMemoryImage('https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png');
@ -130,7 +145,8 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
}
public function testAddMemoryImageFooter(){
public function testAddMemoryImageFooter()
{
$oCell = new PHPWord_Section_Table_Cell('footer', 1);
$element = $oCell->addMemoryImage('https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png');
@ -138,7 +154,8 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
}
public function testAddObjectXLS(){
public function testAddObjectXLS()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
@ -150,7 +167,8 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Object', $element);
}
public function testAddPreserveText(){
public function testAddPreserveText()
{
$oCell = new PHPWord_Section_Table_Cell('header', 1);
$element = $oCell->addPreserveText('text');
@ -158,7 +176,8 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
}
public function testAddPreserveTextNotUTF8(){
public function testAddPreserveTextNotUTF8()
{
$oCell = new PHPWord_Section_Table_Cell('header', 1);
$element = $oCell->addPreserveText(utf8_decode('ééé'));
@ -167,7 +186,8 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($element->getText(), 'ééé');
}
public function testCreateTextRun(){
public function testCreateTextRun()
{
$oCell = new PHPWord_Section_Table_Cell('section', 1);
$element = $oCell->createTextRun();
@ -175,10 +195,10 @@ class PHPWord_Section_Table_CellTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_TextRun', $element);
}
public function testGetElements(){
public function testGetElements()
{
$oCell = new PHPWord_Section_Table_Cell('section', 1);
$this->assertInternalType('array', $oCell->getElements());
}
}

View File

@ -1,11 +1,13 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section\Table;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_Table_Row;
class PHPWord_Section_Table_RowTest extends \PHPUnit_Framework_TestCase {
public function testConstruct(){
class RowTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$iVal = rand(1, 1000);
$oRow = new PHPWord_Section_Table_Row('section', $iVal);
@ -15,16 +17,19 @@ class PHPWord_Section_Table_RowTest extends \PHPUnit_Framework_TestCase {
$this->assertCount(0, $oRow->getCells());
$this->assertInstanceOf('PHPWord_Style_Row', $oRow->getStyle());
}
public function testConstructWithParams(){
public function testConstructWithParams()
{
$iVal = rand(1, 1000);
$iVal2 = rand(1, 1000);
$oRow = new PHPWord_Section_Table_Row('section', $iVal, $iVal2, array('borderBottomSize'=>18, 'borderBottomColor'=>'0000FF', 'bgColor'=>'66BBFF'));
$oRow = new PHPWord_Section_Table_Row('section', $iVal, $iVal2, array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF'));
$this->assertEquals($oRow->getHeight(), $iVal2);
$this->assertInstanceOf('PHPWord_Style_Row', $oRow->getStyle());
}
public function testAddCell(){
public function testAddCell()
{
$oRow = new PHPWord_Section_Table_Row('section', 1);
$element = $oRow->addCell();
@ -32,4 +37,3 @@ class PHPWord_Section_Table_RowTest extends \PHPUnit_Framework_TestCase {
$this->assertCount(1, $oRow->getCells());
}
}

View File

@ -1,11 +1,13 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_Table;
class PHPWord_Section_TableTest extends \PHPUnit_Framework_TestCase {
public function testConstruct() {
class TableTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$oTable = new PHPWord_Section_Table('section', 1);
$this->assertInstanceOf('PHPWord_Section_Table', $oTable);
@ -14,33 +16,42 @@ class PHPWord_Section_TableTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oTable->getRows(), array());
$this->assertCount(0, $oTable->getRows());
}
public function testStyleText() {
public function testStyleText()
{
$oTable = new PHPWord_Section_Table('section', 1, 'tableStyle');
$this->assertEquals($oTable->getStyle(), 'tableStyle');
}
public function testStyleArray() {
$oTable = new PHPWord_Section_Table('section', 1, array('borderSize'=>6, 'borderColor'=>'006699', 'cellMargin'=>80));
public function testStyleArray()
{
$oTable = new PHPWord_Section_Table('section', 1, array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80));
$this->assertInstanceOf('PHPWord_Style_Table', $oTable->getStyle());
}
public function testWidth() {
public function testWidth()
{
$oTable = new PHPWord_Section_Table('section', 1);
$iVal = rand(1, 1000);
$oTable->setWidth($iVal);
$this->assertEquals($oTable->getWidth(), $iVal);
}
public function testRow() {
public function testRow()
{
$oTable = new PHPWord_Section_Table('section', 1);
$element = $oTable->addRow();
$this->assertInstanceOf('PHPWord_Section_Table_Row', $element);
$this->assertCount(1, $oTable->getRows());
}
public function testCell() {
public function testCell()
{
$oTable = new PHPWord_Section_Table('section', 1);
$oTable->addRow();
$element = $oTable->addCell();
$this->assertInstanceOf('PHPWord_Section_Table_Cell', $element);
}
}

View File

@ -1,18 +1,19 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_TextBreak;
class PHPWord_Section_TextBreakTest extends \PHPUnit_Framework_TestCase {
class TextBreakTest extends \PHPUnit_Framework_TestCase
{
/**
* Executed before each method of the class
*/
public function testConstruct() {
public function testConstruct()
{
// Section Settings
$oTextBreak = new PHPWord_Section_TextBreak();
$this->assertInstanceOf('PHPWord_Section_TextBreak', $oTextBreak);
}
}

View File

@ -1,32 +1,40 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_TextRun;
class PHPWord_Section_TextRunTest extends \PHPUnit_Framework_TestCase {
public function testConstructNull() {
class TextRunTest extends \PHPUnit_Framework_TestCase
{
public function testConstructNull()
{
$oTextRun = new PHPWord_Section_TextRun();
$this->assertInstanceOf('PHPWord_Section_TextRun', $oTextRun);
$this->assertCount(0, $oTextRun->getElements());
$this->assertEquals($oTextRun->getParagraphStyle(), null);
}
public function testConstructString() {
public function testConstructString()
{
$oTextRun = new PHPWord_Section_TextRun('pStyle');
$this->assertInstanceOf('PHPWord_Section_TextRun', $oTextRun);
$this->assertCount(0, $oTextRun->getElements());
$this->assertEquals($oTextRun->getParagraphStyle(), 'pStyle');
}
public function testConstructArray() {
$oTextRun = new PHPWord_Section_TextRun(array('spacing'=>100));
public function testConstructArray()
{
$oTextRun = new PHPWord_Section_TextRun(array('spacing' => 100));
$this->assertInstanceOf('PHPWord_Section_TextRun', $oTextRun);
$this->assertCount(0, $oTextRun->getElements());
$this->assertInstanceOf('PHPWord_Style_Paragraph', $oTextRun->getParagraphStyle());
}
public function testAddText() {
public function testAddText()
{
$oTextRun = new PHPWord_Section_TextRun();
$element = $oTextRun->addText('text');
@ -34,7 +42,9 @@ class PHPWord_Section_TextRunTest extends \PHPUnit_Framework_TestCase {
$this->assertCount(1, $oTextRun->getElements());
$this->assertEquals($element->getText(), 'text');
}
public function testAddTextNotUTF8() {
public function testAddTextNotUTF8()
{
$oTextRun = new PHPWord_Section_TextRun();
$element = $oTextRun->addText(utf8_decode('ééé'));
@ -42,7 +52,9 @@ class PHPWord_Section_TextRunTest extends \PHPUnit_Framework_TestCase {
$this->assertCount(1, $oTextRun->getElements());
$this->assertEquals($element->getText(), 'ééé');
}
public function testAddLink() {
public function testAddLink()
{
$oTextRun = new PHPWord_Section_TextRun();
$element = $oTextRun->addLink('http://www.google.fr');
@ -50,7 +62,9 @@ class PHPWord_Section_TextRunTest extends \PHPUnit_Framework_TestCase {
$this->assertCount(1, $oTextRun->getElements());
$this->assertEquals($element->getLinkSrc(), 'http://www.google.fr');
}
public function testAddLinkWithName() {
public function testAddLinkWithName()
{
$oTextRun = new PHPWord_Section_TextRun();
$element = $oTextRun->addLink('http://www.google.fr', utf8_decode('ééé'));
@ -59,7 +73,9 @@ class PHPWord_Section_TextRunTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($element->getLinkSrc(), 'http://www.google.fr');
$this->assertEquals($element->getLinkName(), 'ééé');
}
public function testAddImage() {
public function testAddImage()
{
$src = \join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
@ -70,7 +86,9 @@ class PHPWord_Section_TextRunTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('PHPWord_Section_Image', $element);
$this->assertCount(1, $oTextRun->getElements());
}
public function testCreateFootnote() {
public function testCreateFootnote()
{
$oTextRun = new PHPWord_Section_TextRun();
$element = $oTextRun->createFootnote();
@ -78,4 +96,3 @@ class PHPWord_Section_TextRunTest extends \PHPUnit_Framework_TestCase {
$this->assertCount(1, $oTextRun->getElements());
}
}

View File

@ -1,11 +1,13 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_Text;
class PHPWord_Section_TextTest extends \PHPUnit_Framework_TestCase {
public function testConstruct() {
class TextTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$oText = new PHPWord_Section_Text();
$this->assertInstanceOf('PHPWord_Section_Text', $oText);
@ -13,24 +15,29 @@ class PHPWord_Section_TextTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oText->getFontStyle(), null);
$this->assertEquals($oText->getParagraphStyle(), null);
}
public function testText() {
public function testText()
{
$oText = new PHPWord_Section_Text('text');
$this->assertEquals($oText->getText(), 'text');
}
public function testFont() {
public function testFont()
{
$oText = new PHPWord_Section_Text('text', 'fontStyle');
$this->assertEquals($oText->getFontStyle(), 'fontStyle');
$oText->setFontStyle(array('bold'=>true, 'italic'=>true, 'size'=>16));
$oText->setFontStyle(array('bold' => true, 'italic' => true, 'size' => 16));
$this->assertInstanceOf('PHPWord_Style_Font', $oText->getFontStyle());
}
public function testParagraph() {
public function testParagraph()
{
$oText = new PHPWord_Section_Text('text', 'fontStyle', 'paragraphStyle');
$this->assertEquals($oText->getParagraphStyle(), 'paragraphStyle');
$oText->setParagraphStyle(array('align'=>'center', 'spaceAfter'=>100));
$oText->setParagraphStyle(array('align' => 'center', 'spaceAfter' => 100));
$this->assertInstanceOf('PHPWord_Style_Paragraph', $oText->getParagraphStyle());
}
}

View File

@ -1,34 +1,44 @@
<?php
namespace PHPWord\Tests;
namespace PHPWord\Tests\Section;
use PHPUnit_Framework_TestCase;
use PHPWord_Section_Title;
class PHPWord_Section_TitleTest extends \PHPUnit_Framework_TestCase {
public function testConstruct() {
class TitleTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$oTitle = new PHPWord_Section_Title('text');
$this->assertInstanceOf('PHPWord_Section_Title', $oTitle);
$this->assertEquals($oTitle->getText(), 'text');
}
public function testStyleNull() {
public function testStyleNull()
{
$oTitle = new PHPWord_Section_Title('text');
$this->assertEquals($oTitle->getStyle(), null);
}
public function testStyleNotNull() {
public function testStyleNotNull()
{
$oTitle = new PHPWord_Section_Title('text', 1, 'style');
$this->assertEquals($oTitle->getStyle(), 'style');
}
public function testAnchor() {
public function testAnchor()
{
$oTitle = new PHPWord_Section_Title('text');
$iVal = rand(1, 1000);
$oTitle->setAnchor($iVal);
$this->assertEquals($oTitle->getAnchor(), $iVal);
}
public function testBookmarkID() {
public function testBookmarkID()
{
$oTitle = new PHPWord_Section_Title('text');
$iVal = rand(1, 1000);
@ -36,4 +46,3 @@ class PHPWord_Section_TitleTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($oTitle->getBookmarkId(), $iVal);
}
}