From a6671c2f0f22a29aa8afaecaed0d8872177b0d76 Mon Sep 17 00:00:00 2001 From: Gabriel Bull Date: Sun, 9 Mar 2014 15:04:23 -0400 Subject: [PATCH] Reformatted tests to PSR-2 standards --- .../Section/Footer/PreserveTextTest.php | 47 +-- Tests/PHPWord/Section/FooterTest.php | 173 +++++---- Tests/PHPWord/Section/FootnoteTest.php | 88 +++-- Tests/PHPWord/Section/HeaderTest.php | 240 ++++++------ Tests/PHPWord/Section/ImageTest.php | 102 ++--- Tests/PHPWord/Section/LinkTest.php | 68 ++-- Tests/PHPWord/Section/ListItemTest.php | 39 +- Tests/PHPWord/Section/MemoryImageTest.php | 152 ++++---- Tests/PHPWord/Section/ObjectTest.php | 135 +++---- Tests/PHPWord/Section/PageBreakTest.php | 25 +- Tests/PHPWord/Section/SettingsTest.php | 350 +++++++++--------- Tests/PHPWord/Section/Table/CellTest.php | 300 ++++++++------- Tests/PHPWord/Section/Table/RowTest.php | 56 +-- Tests/PHPWord/Section/TableTest.php | 87 +++-- Tests/PHPWord/Section/TextBreakTest.php | 25 +- Tests/PHPWord/Section/TextRunTest.php | 151 ++++---- Tests/PHPWord/Section/TextTest.php | 61 +-- Tests/PHPWord/Section/TitleTest.php | 67 ++-- 18 files changed, 1157 insertions(+), 1009 deletions(-) diff --git a/Tests/PHPWord/Section/Footer/PreserveTextTest.php b/Tests/PHPWord/Section/Footer/PreserveTextTest.php index fa64c852..ad6b5c24 100644 --- a/Tests/PHPWord/Section/Footer/PreserveTextTest.php +++ b/Tests/PHPWord/Section/Footer/PreserveTextTest.php @@ -1,30 +1,33 @@ assertInstanceOf('PHPWord_Section_Footer_PreserveText', $oPreserveText); - $this->assertEquals($oPreserveText->getText(), null); - $this->assertEquals($oPreserveText->getFontStyle(), null); - $this->assertEquals($oPreserveText->getParagraphStyle(), null); - } + $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $oPreserveText); + $this->assertEquals($oPreserveText->getText(), null); + $this->assertEquals($oPreserveText->getFontStyle(), null); + $this->assertEquals($oPreserveText->getParagraphStyle(), null); + } - 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 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)); - $this->assertInstanceOf('PHPWord_Style_Font', $oPreserveText->getFontStyle()); - $this->assertInstanceOf('PHPWord_Style_Paragraph', $oPreserveText->getParagraphStyle()); - } -} - \ No newline at end of file + 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()); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/FooterTest.php b/Tests/PHPWord/Section/FooterTest.php index dc4b5c67..46999b59 100644 --- a/Tests/PHPWord/Section/FooterTest.php +++ b/Tests/PHPWord/Section/FooterTest.php @@ -1,110 +1,121 @@ assertInstanceOf('PHPWord_Section_Footer', $oFooter); + $this->assertEquals($oFooter->getFooterCount(), $iVal); + } - $this->assertInstanceOf('PHPWord_Section_Footer', $oFooter); - $this->assertEquals($oFooter->getFooterCount(), $iVal); - } + public function testRelationID() + { + $oFooter = new PHPWord_Section_Footer(0); - public function testRelationID(){ - $oFooter = new PHPWord_Section_Footer(0); + $iVal = rand(1, 1000); + $oFooter->setRelationId($iVal); + $this->assertEquals($oFooter->getRelationId(), $iVal); + } - $iVal = rand(1, 1000); - $oFooter->setRelationId($iVal); - $this->assertEquals($oFooter->getRelationId(), $iVal); - } + public function testAddText() + { + $oFooter = new PHPWord_Section_Footer(1); + $element = $oFooter->addText('text'); - public function testAddText(){ - $oFooter = new PHPWord_Section_Footer(1); - $element = $oFooter->addText('text'); + $this->assertCount(1, $oFooter->getElements()); + $this->assertInstanceOf('PHPWord_Section_Text', $element); - $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_Text', $element); + } - } + public function testAddTextNotUTF8() + { + $oFooter = new PHPWord_Section_Footer(1); + $element = $oFooter->addText(utf8_decode('ééé')); - public function testAddTextNotUTF8(){ - $oFooter = new PHPWord_Section_Footer(1); - $element = $oFooter->addText(utf8_decode('ééé')); + $this->assertCount(1, $oFooter->getElements()); + $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertEquals($element->getText(), 'ééé'); + } - $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_Text', $element); - $this->assertEquals($element->getText(), 'ééé'); - } + public function testAddTextBreak() + { + $oFooter = new PHPWord_Section_Footer(1); + $iVal = rand(1, 1000); + $oFooter->addTextBreak($iVal); - public function testAddTextBreak(){ - $oFooter = new PHPWord_Section_Footer(1); - $iVal = rand(1, 1000); - $oFooter->addTextBreak($iVal); + $this->assertCount($iVal, $oFooter->getElements()); + } - $this->assertCount($iVal, $oFooter->getElements()); - } + public function testCreateTextRun() + { + $oFooter = new PHPWord_Section_Footer(1); + $element = $oFooter->createTextRun(); - public function testCreateTextRun(){ - $oFooter = new PHPWord_Section_Footer(1); - $element = $oFooter->createTextRun(); + $this->assertCount(1, $oFooter->getElements()); + $this->assertInstanceOf('PHPWord_Section_TextRun', $element); + } - $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_TextRun', $element); - } + public function testAddTable() + { + $oFooter = new PHPWord_Section_Footer(1); + $element = $oFooter->addTable(); - public function testAddTable(){ - $oFooter = new PHPWord_Section_Footer(1); - $element = $oFooter->addTable(); + $this->assertCount(1, $oFooter->getElements()); + $this->assertInstanceOf('PHPWord_Section_Table', $element); + } - $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_Table', $element); - } + public function testAddImage() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + ); + $oFooter = new PHPWord_Section_Footer(1); + $element = $oFooter->addImage($src); - public function testAddImage(){ - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') - ); - $oFooter = new PHPWord_Section_Footer(1); - $element = $oFooter->addImage($src); + $this->assertCount(1, $oFooter->getElements()); + $this->assertInstanceOf('PHPWord_Section_Image', $element); + } - $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_Image', $element); - } + 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'); - 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'); + $this->assertCount(1, $oFooter->getElements()); + $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); + } - $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); - } + public function testAddPreserveText() + { + $oFooter = new PHPWord_Section_Footer(1); + $element = $oFooter->addPreserveText('text'); - public function testAddPreserveText(){ - $oFooter = new PHPWord_Section_Footer(1); - $element = $oFooter->addPreserveText('text'); + $this->assertCount(1, $oFooter->getElements()); + $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); + } - $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); - } + public function testAddPreserveTextNotUTF8() + { + $oFooter = new PHPWord_Section_Footer(1); + $element = $oFooter->addPreserveText(utf8_decode('ééé')); - public function testAddPreserveTextNotUTF8(){ - $oFooter = new PHPWord_Section_Footer(1); - $element = $oFooter->addPreserveText(utf8_decode('ééé')); + $this->assertCount(1, $oFooter->getElements()); + $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); + $this->assertEquals($element->getText(), 'ééé'); + } - $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); - $this->assertEquals($element->getText(), 'ééé'); - } + public function testGetElements() + { + $oFooter = new PHPWord_Section_Footer(1); - public function testGetElements(){ - $oFooter = new PHPWord_Section_Footer(1); - - $this->assertInternalType('array', $oFooter->getElements()); - } -} - \ No newline at end of file + $this->assertInternalType('array', $oFooter->getElements()); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/FootnoteTest.php b/Tests/PHPWord/Section/FootnoteTest.php index 8519728a..a1f26494 100644 --- a/Tests/PHPWord/Section/FootnoteTest.php +++ b/Tests/PHPWord/Section/FootnoteTest.php @@ -1,58 +1,64 @@ assertInstanceOf('PHPWord_Section_Footnote', $oFootnote); + $this->assertCount(0, $oFootnote->getElements()); + $this->assertEquals($oFootnote->getParagraphStyle(), null); + } - $this->assertInstanceOf('PHPWord_Section_Footnote', $oFootnote); - $this->assertCount(0, $oFootnote->getElements()); - $this->assertEquals($oFootnote->getParagraphStyle(), null); - } + public function testConstructString() + { + $oFootnote = new PHPWord_Section_Footnote('pStyle'); - public function testConstructString(){ - $oFootnote = new PHPWord_Section_Footnote('pStyle'); + $this->assertEquals($oFootnote->getParagraphStyle(), 'pStyle'); + } - $this->assertEquals($oFootnote->getParagraphStyle(), 'pStyle'); - } + public function testConstructArray() + { + $oFootnote = new PHPWord_Section_Footnote(array('spacing' => 100)); - public function testConstructArray(){ - $oFootnote = new PHPWord_Section_Footnote(array('spacing' => 100)); + $this->assertInstanceOf('PHPWord_Style_Paragraph', $oFootnote->getParagraphStyle()); + } - $this->assertInstanceOf('PHPWord_Style_Paragraph', $oFootnote->getParagraphStyle()); - } + public function testAddText() + { + $oFootnote = new PHPWord_Section_Footnote(); + $element = $oFootnote->addText('text'); - public function testAddText(){ - $oFootnote = new PHPWord_Section_Footnote(); - $element = $oFootnote->addText('text'); + $this->assertCount(1, $oFootnote->getElements()); + $this->assertInstanceOf('PHPWord_Section_Text', $element); + } - $this->assertCount(1, $oFootnote->getElements()); - $this->assertInstanceOf('PHPWord_Section_Text', $element); - } + public function testAddLink() + { + $oFootnote = new PHPWord_Section_Footnote(); + $element = $oFootnote->addLink('http://www.google.fr'); - public function testAddLink(){ - $oFootnote = new PHPWord_Section_Footnote(); - $element = $oFootnote->addLink('http://www.google.fr'); + $this->assertCount(1, $oFootnote->getElements()); + $this->assertInstanceOf('PHPWord_Section_Link', $element); + } - $this->assertCount(1, $oFootnote->getElements()); - $this->assertInstanceOf('PHPWord_Section_Link', $element); - } + public function testReferenceId() + { + $oFootnote = new PHPWord_Section_Footnote(); - public function testReferenceId(){ - $oFootnote = new PHPWord_Section_Footnote(); + $iVal = rand(1, 1000); + $oFootnote->setReferenceId($iVal); + $this->assertEquals($oFootnote->getReferenceId(), $iVal); + } - $iVal = rand(1, 1000); - $oFootnote->setReferenceId($iVal); - $this->assertEquals($oFootnote->getReferenceId(), $iVal); - } - - public function testGetElements(){ - $oFootnote = new PHPWord_Section_Footnote(); - $this->assertInternalType('array', $oFootnote->getElements()); - } -} - \ No newline at end of file + public function testGetElements() + { + $oFootnote = new PHPWord_Section_Footnote(); + $this->assertInternalType('array', $oFootnote->getElements()); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/HeaderTest.php b/Tests/PHPWord/Section/HeaderTest.php index 9f0f728f..d7dc3ace 100644 --- a/Tests/PHPWord/Section/HeaderTest.php +++ b/Tests/PHPWord/Section/HeaderTest.php @@ -1,146 +1,164 @@ assertInstanceOf('PHPWord_Section_Header', $oHeader); - $this->assertEquals($oHeader->getHeaderCount(), $iVal); - $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::AUTO); - } + $this->assertInstanceOf('PHPWord_Section_Header', $oHeader); + $this->assertEquals($oHeader->getHeaderCount(), $iVal); + $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::AUTO); + } - public function testAddText(){ - $oHeader = new PHPWord_Section_Header(1); - $element = $oHeader->addText('text'); + public function testAddText() + { + $oHeader = new PHPWord_Section_Header(1); + $element = $oHeader->addText('text'); - $this->assertInstanceOf('PHPWord_Section_Text', $element); - $this->assertCount(1, $oHeader->getElements()); - $this->assertEquals($element->getText(), 'text'); - } + $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertCount(1, $oHeader->getElements()); + $this->assertEquals($element->getText(), 'text'); + } - public function testAddTextNotUTF8(){ - $oHeader = new PHPWord_Section_Header(1); - $element = $oHeader->addText(utf8_decode('ééé')); + public function testAddTextNotUTF8() + { + $oHeader = new PHPWord_Section_Header(1); + $element = $oHeader->addText(utf8_decode('ééé')); - $this->assertInstanceOf('PHPWord_Section_Text', $element); - $this->assertCount(1, $oHeader->getElements()); - $this->assertEquals($element->getText(), 'ééé'); - } + $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertCount(1, $oHeader->getElements()); + $this->assertEquals($element->getText(), 'ééé'); + } - public function testAddTextBreak(){ - $oHeader = new PHPWord_Section_Header(1); - $oHeader->addTextBreak(); - $this->assertCount(1, $oHeader->getElements()); - } + public function testAddTextBreak() + { + $oHeader = new PHPWord_Section_Header(1); + $oHeader->addTextBreak(); + $this->assertCount(1, $oHeader->getElements()); + } - public function testAddTextBreakWithParams(){ - $oHeader = new PHPWord_Section_Header(1); - $iVal = rand(1, 1000); - $oHeader->addTextBreak($iVal); - $this->assertCount($iVal, $oHeader->getElements()); - } + public function testAddTextBreakWithParams() + { + $oHeader = new PHPWord_Section_Header(1); + $iVal = rand(1, 1000); + $oHeader->addTextBreak($iVal); + $this->assertCount($iVal, $oHeader->getElements()); + } - 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 testCreateTextRun() + { + $oHeader = new PHPWord_Section_Header(1); + $element = $oHeader->createTextRun(); + $this->assertInstanceOf('PHPWord_Section_TextRun', $element); + $this->assertCount(1, $oHeader->getElements()); + } - 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 testAddTable() + { + $oHeader = new PHPWord_Section_Header(1); + $element = $oHeader->addTable(); + $this->assertInstanceOf('PHPWord_Section_Table', $element); + $this->assertCount(1, $oHeader->getElements()); + } - public function testAddImage(){ - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') - ); - $oHeader = new PHPWord_Section_Header(1); - $element = $oHeader->addImage($src); + public function testAddImage() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + ); + $oHeader = new PHPWord_Section_Header(1); + $element = $oHeader->addImage($src); - $this->assertCount(1, $oHeader->getElements()); - $this->assertInstanceOf('PHPWord_Section_Image', $element); - } + $this->assertCount(1, $oHeader->getElements()); + $this->assertInstanceOf('PHPWord_Section_Image', $element); + } - 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'); + 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'); - $this->assertCount(1, $oHeader->getElements()); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); - } + $this->assertCount(1, $oHeader->getElements()); + $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); + } - public function testAddPreserveText(){ - $oHeader = new PHPWord_Section_Header(1); - $element = $oHeader->addPreserveText('text'); + public function testAddPreserveText() + { + $oHeader = new PHPWord_Section_Header(1); + $element = $oHeader->addPreserveText('text'); - $this->assertCount(1, $oHeader->getElements()); - $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); - } + $this->assertCount(1, $oHeader->getElements()); + $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); + } - public function testAddPreserveTextNotUTF8(){ - $oHeader = new PHPWord_Section_Header(1); - $element = $oHeader->addPreserveText(utf8_decode('ééé')); + public function testAddPreserveTextNotUTF8() + { + $oHeader = new PHPWord_Section_Header(1); + $element = $oHeader->addPreserveText(utf8_decode('ééé')); - $this->assertCount(1, $oHeader->getElements()); - $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); - $this->assertEquals($element->getText(), 'ééé'); - } + $this->assertCount(1, $oHeader->getElements()); + $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); + $this->assertEquals($element->getText(), 'ééé'); + } - public function testAddWatermark(){ - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') - ); - $oHeader = new PHPWord_Section_Header(1); - $element = $oHeader->addWatermark($src); + public function testAddWatermark() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + ); + $oHeader = new PHPWord_Section_Header(1); + $element = $oHeader->addWatermark($src); - $this->assertCount(1, $oHeader->getElements()); - $this->assertInstanceOf('PHPWord_Section_Image', $element); - } + $this->assertCount(1, $oHeader->getElements()); + $this->assertInstanceOf('PHPWord_Section_Image', $element); + } - public function testGetElements(){ - $oHeader = new PHPWord_Section_Header(1); + public function testGetElements() + { + $oHeader = new PHPWord_Section_Header(1); - $this->assertInternalType('array', $oHeader->getElements()); - } + $this->assertInternalType('array', $oHeader->getElements()); + } - public function testRelationId(){ - $oHeader = new PHPWord_Section_Header(1); + public function testRelationId() + { + $oHeader = new PHPWord_Section_Header(1); - $iVal = rand(1, 1000); - $oHeader->setRelationId($iVal); - $this->assertEquals($oHeader->getRelationId(), $iVal); - } + $iVal = rand(1, 1000); + $oHeader->setRelationId($iVal); + $this->assertEquals($oHeader->getRelationId(), $iVal); + } - public function testResetType(){ - $oHeader = new PHPWord_Section_Header(1); - $oHeader->firstPage(); - $oHeader->resetType(); + public function testResetType() + { + $oHeader = new PHPWord_Section_Header(1); + $oHeader->firstPage(); + $oHeader->resetType(); - $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::AUTO); - } + $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::AUTO); + } - public function testFirstPage(){ - $oHeader = new PHPWord_Section_Header(1); - $oHeader->firstPage(); + public function testFirstPage() + { + $oHeader = new PHPWord_Section_Header(1); + $oHeader->firstPage(); - $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::FIRST); - } + $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::FIRST); + } - public function testEvenPage(){ - $oHeader = new PHPWord_Section_Header(1); - $oHeader->evenPage(); + public function testEvenPage() + { + $oHeader = new PHPWord_Section_Header(1); + $oHeader->evenPage(); - $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::EVEN); - } + $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::EVEN); + } } \ No newline at end of file diff --git a/Tests/PHPWord/Section/ImageTest.php b/Tests/PHPWord/Section/ImageTest.php index f7c7dbcd..4e265db7 100644 --- a/Tests/PHPWord/Section/ImageTest.php +++ b/Tests/PHPWord/Section/ImageTest.php @@ -1,62 +1,68 @@ assertInstanceOf('PHPWord_Section_Image', $oImage); - $this->assertEquals($oImage->getSource(), $src); - $this->assertEquals($oImage->getMediaId(), md5($src)); - $this->assertEquals($oImage->getIsWatermark(), false); - $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle()); - } - 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)); + $this->assertInstanceOf('PHPWord_Section_Image', $oImage); + $this->assertEquals($oImage->getSource(), $src); + $this->assertEquals($oImage->getMediaId(), md5($src)); + $this->assertEquals($oImage->getIsWatermark(), false); + $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle()); + } - $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle()); - } + 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)); - 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')); + $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle()); + } - $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle()); - } + 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')); - public function testRelationID(){ - $oImage = new PHPWord_Section_Image(\join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') - )); + $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle()); + } - $iVal = rand(1, 1000); - $oImage->setRelationId($iVal); - $this->assertEquals($oImage->getRelationId(), $iVal); - } + public function testRelationID() + { + $oImage = new PHPWord_Section_Image(\join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + )); - public function testWatermark(){ - $oImage = new PHPWord_Section_Image(\join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') - )); + $iVal = rand(1, 1000); + $oImage->setRelationId($iVal); + $this->assertEquals($oImage->getRelationId(), $iVal); + } - $oImage->setIsWatermark(true); - $this->assertEquals($oImage->getIsWatermark(), true); - } -} - \ No newline at end of file + public function testWatermark() + { + $oImage = new PHPWord_Section_Image(\join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + )); + + $oImage->setIsWatermark(true); + $this->assertEquals($oImage->getIsWatermark(), true); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/LinkTest.php b/Tests/PHPWord/Section/LinkTest.php index 9769167c..c9f1bdca 100644 --- a/Tests/PHPWord/Section/LinkTest.php +++ b/Tests/PHPWord/Section/LinkTest.php @@ -1,42 +1,48 @@ assertInstanceOf('PHPWord_Section_Link', $oLink); - $this->assertEquals($oLink->getLinkSrc(), 'http://www.google.com'); - $this->assertEquals($oLink->getLinkName(), null); - $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)); + $this->assertInstanceOf('PHPWord_Section_Link', $oLink); + $this->assertEquals($oLink->getLinkSrc(), 'http://www.google.com'); + $this->assertEquals($oLink->getLinkName(), null); + $this->assertEquals($oLink->getFontStyle(), null); + $this->assertEquals($oLink->getParagraphStyle(), null); + } - $this->assertInstanceOf('PHPWord_Section_Link', $oLink); - $this->assertEquals($oLink->getLinkSrc(), 'http://www.google.com'); - $this->assertEquals($oLink->getLinkName(), 'Search Engine'); - $this->assertInstanceOf('PHPWord_Style_Font', $oLink->getFontStyle()); - $this->assertInstanceOf('PHPWord_Style_Paragraph', $oLink->getParagraphStyle()); - } - public function testConstructWithParamsString() { - $oLink = new PHPWord_Section_Link('http://www.google.com', null, 'fontStyle', 'paragraphStyle'); + 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->assertEquals($oLink->getFontStyle(), 'fontStyle'); - $this->assertEquals($oLink->getParagraphStyle(), 'paragraphStyle'); - } + $this->assertInstanceOf('PHPWord_Section_Link', $oLink); + $this->assertEquals($oLink->getLinkSrc(), 'http://www.google.com'); + $this->assertEquals($oLink->getLinkName(), 'Search Engine'); + $this->assertInstanceOf('PHPWord_Style_Font', $oLink->getFontStyle()); + $this->assertInstanceOf('PHPWord_Style_Paragraph', $oLink->getParagraphStyle()); + } - public function testRelationId(){ - $oLink = new PHPWord_Section_Link('http://www.google.com'); + public function testConstructWithParamsString() + { + $oLink = new PHPWord_Section_Link('http://www.google.com', null, 'fontStyle', 'paragraphStyle'); - $iVal = rand(1, 1000); - $oLink->setRelationId($iVal); - $this->assertEquals($oLink->getRelationId(), $iVal); - } -} - \ No newline at end of file + $this->assertEquals($oLink->getFontStyle(), 'fontStyle'); + $this->assertEquals($oLink->getParagraphStyle(), 'paragraphStyle'); + } + + public function testRelationId() + { + $oLink = new PHPWord_Section_Link('http://www.google.com'); + + $iVal = rand(1, 1000); + $oLink->setRelationId($iVal); + $this->assertEquals($oLink->getRelationId(), $iVal); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/ListItemTest.php b/Tests/PHPWord/Section/ListItemTest.php index 6b99234d..0b656eed 100644 --- a/Tests/PHPWord/Section/ListItemTest.php +++ b/Tests/PHPWord/Section/ListItemTest.php @@ -1,29 +1,32 @@ assertInstanceOf('PHPWord_Section_Text', $oListItem->getTextObject()); + } - $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); + } - $this->assertInstanceOf('PHPWord_Style_ListItem', $oListItem->getStyle()); - $this->assertEquals($oListItem->getStyle()->getListType(), PHPWord_Style_ListItem::TYPE_NUMBER); - } - public function testDepth(){ - $iVal = rand(1, 1000); - $oListItem = new PHPWord_Section_ListItem('text', $iVal); + public function testDepth() + { + $iVal = rand(1, 1000); + $oListItem = new PHPWord_Section_ListItem('text', $iVal); - $this->assertEquals($oListItem->getDepth(), $iVal); - } -} - \ No newline at end of file + $this->assertEquals($oListItem->getDepth(), $iVal); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/MemoryImageTest.php b/Tests/PHPWord/Section/MemoryImageTest.php index ff11bc95..9b9694d9 100644 --- a/Tests/PHPWord/Section/MemoryImageTest.php +++ b/Tests/PHPWord/Section/MemoryImageTest.php @@ -1,89 +1,95 @@ assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage); - $this->assertEquals($oMemoryImage->getSource(), $src); - $this->assertEquals($oMemoryImage->getMediaId(), md5($src)); - $this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefrompng'); - $this->assertEquals($oMemoryImage->getImageFunction(), 'imagepng'); - $this->assertEquals($oMemoryImage->getImageExtension(), 'png'); - $this->assertEquals($oMemoryImage->getImageType(), 'image/png'); - } + $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage); + $this->assertEquals($oMemoryImage->getSource(), $src); + $this->assertEquals($oMemoryImage->getMediaId(), md5($src)); + $this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefrompng'); + $this->assertEquals($oMemoryImage->getImageFunction(), 'imagepng'); + $this->assertEquals($oMemoryImage->getImageExtension(), 'png'); + $this->assertEquals($oMemoryImage->getImageType(), 'image/png'); + } - public function testGIF() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'mario.gif') - ); - $oMemoryImage = new PHPWord_Section_MemoryImage($src); + public function testGIF() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'mario.gif') + ); + $oMemoryImage = new PHPWord_Section_MemoryImage($src); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage); - $this->assertEquals($oMemoryImage->getSource(), $src); - $this->assertEquals($oMemoryImage->getMediaId(), md5($src)); - $this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefromgif'); - $this->assertEquals($oMemoryImage->getImageFunction(), 'imagegif'); - $this->assertEquals($oMemoryImage->getImageExtension(), 'gif'); - $this->assertEquals($oMemoryImage->getImageType(), 'image/gif'); - } + $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage); + $this->assertEquals($oMemoryImage->getSource(), $src); + $this->assertEquals($oMemoryImage->getMediaId(), md5($src)); + $this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefromgif'); + $this->assertEquals($oMemoryImage->getImageFunction(), 'imagegif'); + $this->assertEquals($oMemoryImage->getImageExtension(), 'gif'); + $this->assertEquals($oMemoryImage->getImageType(), 'image/gif'); + } - public function testJPG() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') - ); - $oMemoryImage = new PHPWord_Section_MemoryImage($src); + public function testJPG() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + ); + $oMemoryImage = new PHPWord_Section_MemoryImage($src); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage); - $this->assertEquals($oMemoryImage->getSource(), $src); - $this->assertEquals($oMemoryImage->getMediaId(), md5($src)); - $this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefromjpeg'); - $this->assertEquals($oMemoryImage->getImageFunction(), 'imagejpeg'); - $this->assertEquals($oMemoryImage->getImageExtension(), 'jpg'); - $this->assertEquals($oMemoryImage->getImageType(), 'image/jpeg'); - } + $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage); + $this->assertEquals($oMemoryImage->getSource(), $src); + $this->assertEquals($oMemoryImage->getMediaId(), md5($src)); + $this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefromjpeg'); + $this->assertEquals($oMemoryImage->getImageFunction(), 'imagejpeg'); + $this->assertEquals($oMemoryImage->getImageExtension(), 'jpg'); + $this->assertEquals($oMemoryImage->getImageType(), 'image/jpeg'); + } - public function testBMP() { - $oMemoryImage = new PHPWord_Section_MemoryImage(\join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'duke_nukem.bmp') - )); + public function testBMP() + { + $oMemoryImage = new PHPWord_Section_MemoryImage(\join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'duke_nukem.bmp') + )); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage); - $this->assertEquals($oMemoryImage->getImageCreateFunction(), null); - $this->assertEquals($oMemoryImage->getImageFunction(), null); - $this->assertEquals($oMemoryImage->getImageExtension(), null); - $this->assertEquals($oMemoryImage->getImageType(), 'image/x-ms-bmp'); - } + $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage); + $this->assertEquals($oMemoryImage->getImageCreateFunction(), null); + $this->assertEquals($oMemoryImage->getImageFunction(), null); + $this->assertEquals($oMemoryImage->getImageExtension(), null); + $this->assertEquals($oMemoryImage->getImageType(), 'image/x-ms-bmp'); + } - 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')); + 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')); - $this->assertInstanceOf('PHPWord_Style_Image', $oMemoryImage->getStyle()); - } + $this->assertInstanceOf('PHPWord_Style_Image', $oMemoryImage->getStyle()); + } - public function testRelationID(){ - $oMemoryImage = new PHPWord_Section_MemoryImage(\join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') - )); + public function testRelationID() + { + $oMemoryImage = new PHPWord_Section_MemoryImage(\join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + )); - $iVal = rand(1, 1000); - $oMemoryImage->setRelationId($iVal); - $this->assertEquals($oMemoryImage->getRelationId(), $iVal); - } -} - \ No newline at end of file + $iVal = rand(1, 1000); + $oMemoryImage->setRelationId($iVal); + $this->assertEquals($oMemoryImage->getRelationId(), $iVal); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/ObjectTest.php b/Tests/PHPWord/Section/ObjectTest.php index e278addc..fa5fa24b 100644 --- a/Tests/PHPWord/Section/ObjectTest.php +++ b/Tests/PHPWord/Section/ObjectTest.php @@ -1,79 +1,86 @@ assertInstanceOf('PHPWord_Section_Object', $oObject); - $this->assertInstanceOf('PHPWord_Style_Image', $oObject->getStyle()); - $this->assertEquals($oObject->getSource(), $src); - } - public function testConstructWithNotSupportedFiles() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl') - ); - $oObject = new PHPWord_Section_Object($src); + $this->assertInstanceOf('PHPWord_Section_Object', $oObject); + $this->assertInstanceOf('PHPWord_Style_Image', $oObject->getStyle()); + $this->assertEquals($oObject->getSource(), $src); + } - $this->assertInstanceOf('PHPWord_Section_Object', $oObject); - $this->assertEquals($oObject->getSource(), null); - $this->assertEquals($oObject->getStyle(), null); - } + public function testConstructWithNotSupportedFiles() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl') + ); + $oObject = new PHPWord_Section_Object($src); - public function testConstructWithSupportedFilesAndStyle() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') - ); - $oObject = new PHPWord_Section_Object($src, array('width' => '230px')); + $this->assertInstanceOf('PHPWord_Section_Object', $oObject); + $this->assertEquals($oObject->getSource(), null); + $this->assertEquals($oObject->getStyle(), null); + } - $this->assertInstanceOf('PHPWord_Section_Object', $oObject); - $this->assertInstanceOf('PHPWord_Style_Image', $oObject->getStyle()); - $this->assertEquals($oObject->getSource(), $src); - } + public function testConstructWithSupportedFilesAndStyle() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + ); + $oObject = new PHPWord_Section_Object($src, array('width' => '230px')); - public function testRelationId(){ - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') - ); - $oObject = new PHPWord_Section_Object($src); + $this->assertInstanceOf('PHPWord_Section_Object', $oObject); + $this->assertInstanceOf('PHPWord_Style_Image', $oObject->getStyle()); + $this->assertEquals($oObject->getSource(), $src); + } - $iVal = rand(1, 1000); - $oObject->setRelationId($iVal); - $this->assertEquals($oObject->getRelationId(), $iVal); - } + public function testRelationId() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + ); + $oObject = new PHPWord_Section_Object($src); - public function testImageRelationId(){ - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') - ); - $oObject = new PHPWord_Section_Object($src); + $iVal = rand(1, 1000); + $oObject->setRelationId($iVal); + $this->assertEquals($oObject->getRelationId(), $iVal); + } - $iVal = rand(1, 1000); - $oObject->setImageRelationId($iVal); - $this->assertEquals($oObject->getImageRelationId(), $iVal); - } + public function testImageRelationId() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + ); + $oObject = new PHPWord_Section_Object($src); - public function testObjectId(){ - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') - ); - $oObject = new PHPWord_Section_Object($src); + $iVal = rand(1, 1000); + $oObject->setImageRelationId($iVal); + $this->assertEquals($oObject->getImageRelationId(), $iVal); + } - $iVal = rand(1, 1000); - $oObject->setObjectId($iVal); - $this->assertEquals($oObject->getObjectId(), $iVal); - } -} - \ No newline at end of file + public function testObjectId() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + ); + $oObject = new PHPWord_Section_Object($src); + + $iVal = rand(1, 1000); + $oObject->setObjectId($iVal); + $this->assertEquals($oObject->getObjectId(), $iVal); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/PageBreakTest.php b/Tests/PHPWord/Section/PageBreakTest.php index 0649a501..01944d06 100644 --- a/Tests/PHPWord/Section/PageBreakTest.php +++ b/Tests/PHPWord/Section/PageBreakTest.php @@ -1,18 +1,19 @@ assertInstanceOf('PHPWord_Section_PageBreak', $oPageBreak); - } -} - \ No newline at end of file + $this->assertInstanceOf('PHPWord_Section_PageBreak', $oPageBreak); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/SettingsTest.php b/Tests/PHPWord/Section/SettingsTest.php index 7c7df42a..83c1c888 100644 --- a/Tests/PHPWord/Section/SettingsTest.php +++ b/Tests/PHPWord/Section/SettingsTest.php @@ -1,224 +1,236 @@ setSettingValue('_orientation', 'landscape'); - $this->assertEquals($oSettings->getOrientation(), 'landscape'); - $this->assertEquals($oSettings->getPageSizeW(), 16838); - $this->assertEquals($oSettings->getPageSizeH(), 11906); + $oSettings->setSettingValue('_orientation', 'landscape'); + $this->assertEquals($oSettings->getOrientation(), 'landscape'); + $this->assertEquals($oSettings->getPageSizeW(), 16838); + $this->assertEquals($oSettings->getPageSizeH(), 11906); - $oSettings->setSettingValue('_orientation', null); - $this->assertEquals($oSettings->getOrientation(), null); - $this->assertEquals($oSettings->getPageSizeW(), 11906); - $this->assertEquals($oSettings->getPageSizeH(), 16838); + $oSettings->setSettingValue('_orientation', null); + $this->assertEquals($oSettings->getOrientation(), null); + $this->assertEquals($oSettings->getPageSizeW(), 11906); + $this->assertEquals($oSettings->getPageSizeH(), 16838); - $iVal = rand(1, 1000); - $oSettings->setSettingValue('_borderSize', $iVal); - $this->assertEquals($oSettings->getBorderSize(), array($iVal, $iVal, $iVal, $iVal)); - $this->assertEquals($oSettings->getBorderBottomSize(), $iVal); - $this->assertEquals($oSettings->getBorderLeftSize(), $iVal); - $this->assertEquals($oSettings->getBorderRightSize(), $iVal); - $this->assertEquals($oSettings->getBorderTopSize(), $iVal); + $iVal = rand(1, 1000); + $oSettings->setSettingValue('_borderSize', $iVal); + $this->assertEquals($oSettings->getBorderSize(), array($iVal, $iVal, $iVal, $iVal)); + $this->assertEquals($oSettings->getBorderBottomSize(), $iVal); + $this->assertEquals($oSettings->getBorderLeftSize(), $iVal); + $this->assertEquals($oSettings->getBorderRightSize(), $iVal); + $this->assertEquals($oSettings->getBorderTopSize(), $iVal); - $oSettings->setSettingValue('_borderColor', 'FF00AA'); - $this->assertEquals($oSettings->getBorderColor(), array('FF00AA', 'FF00AA', 'FF00AA', 'FF00AA')); - $this->assertEquals($oSettings->getBorderBottomColor(), 'FF00AA'); - $this->assertEquals($oSettings->getBorderLeftColor(), 'FF00AA'); - $this->assertEquals($oSettings->getBorderRightColor(), 'FF00AA'); - $this->assertEquals($oSettings->getBorderTopColor(), 'FF00AA'); + $oSettings->setSettingValue('_borderColor', 'FF00AA'); + $this->assertEquals($oSettings->getBorderColor(), array('FF00AA', 'FF00AA', 'FF00AA', 'FF00AA')); + $this->assertEquals($oSettings->getBorderBottomColor(), 'FF00AA'); + $this->assertEquals($oSettings->getBorderLeftColor(), 'FF00AA'); + $this->assertEquals($oSettings->getBorderRightColor(), 'FF00AA'); + $this->assertEquals($oSettings->getBorderTopColor(), 'FF00AA'); - $iVal = rand(1, 1000); - $oSettings->setSettingValue('headerHeight', $iVal); - $this->assertEquals($oSettings->getHeaderHeight(), $iVal); - } + $iVal = rand(1, 1000); + $oSettings->setSettingValue('headerHeight', $iVal); + $this->assertEquals($oSettings->getHeaderHeight(), $iVal); + } - public function testMargin(){ - // Section Settings - $oSettings = new PHPWord_Section_Settings(); + public function testMargin() + { + // Section Settings + $oSettings = new PHPWord_Section_Settings(); - $iVal = rand(1, 1000); - $oSettings->setMarginTop($iVal); - $this->assertEquals($oSettings->getMarginTop(), $iVal); + $iVal = rand(1, 1000); + $oSettings->setMarginTop($iVal); + $this->assertEquals($oSettings->getMarginTop(), $iVal); - $iVal = rand(1, 1000); - $oSettings->setMarginBottom($iVal); - $this->assertEquals($oSettings->getMarginBottom(), $iVal); + $iVal = rand(1, 1000); + $oSettings->setMarginBottom($iVal); + $this->assertEquals($oSettings->getMarginBottom(), $iVal); - $iVal = rand(1, 1000); - $oSettings->setMarginLeft($iVal); - $this->assertEquals($oSettings->getMarginLeft(), $iVal); + $iVal = rand(1, 1000); + $oSettings->setMarginLeft($iVal); + $this->assertEquals($oSettings->getMarginLeft(), $iVal); - $iVal = rand(1, 1000); - $oSettings->setMarginRight($iVal); - $this->assertEquals($oSettings->getMarginRight(), $iVal); - } + $iVal = rand(1, 1000); + $oSettings->setMarginRight($iVal); + $this->assertEquals($oSettings->getMarginRight(), $iVal); + } - public function testOrientationLandscape(){ - // Section Settings - $oSettings = new PHPWord_Section_Settings(); + public function testOrientationLandscape() + { + // Section Settings + $oSettings = new PHPWord_Section_Settings(); - $oSettings->setLandscape(); - $this->assertEquals($oSettings->getOrientation(), 'landscape'); - $this->assertEquals($oSettings->getPageSizeW(), 16838); - $this->assertEquals($oSettings->getPageSizeH(), 11906); - } + $oSettings->setLandscape(); + $this->assertEquals($oSettings->getOrientation(), 'landscape'); + $this->assertEquals($oSettings->getPageSizeW(), 16838); + $this->assertEquals($oSettings->getPageSizeH(), 11906); + } - public function testOrientationPortrait(){ - // Section Settings - $oSettings = new PHPWord_Section_Settings(); + public function testOrientationPortrait() + { + // Section Settings + $oSettings = new PHPWord_Section_Settings(); - $oSettings->setPortrait(); - $this->assertEquals($oSettings->getOrientation(), null); - $this->assertEquals($oSettings->getPageSizeW(), 11906); - $this->assertEquals($oSettings->getPageSizeH(), 16838); - } + $oSettings->setPortrait(); + $this->assertEquals($oSettings->getOrientation(), null); + $this->assertEquals($oSettings->getPageSizeW(), 11906); + $this->assertEquals($oSettings->getPageSizeH(), 16838); + } - public function testBorderSize(){ - // Section Settings - $oSettings = new PHPWord_Section_Settings(); + public function testBorderSize() + { + // Section Settings + $oSettings = new PHPWord_Section_Settings(); - $iVal = rand(1, 1000); - $oSettings->setBorderSize($iVal); - $this->assertEquals($oSettings->getBorderSize(), array($iVal, $iVal, $iVal, $iVal)); - $this->assertEquals($oSettings->getBorderBottomSize(), $iVal); - $this->assertEquals($oSettings->getBorderLeftSize(), $iVal); - $this->assertEquals($oSettings->getBorderRightSize(), $iVal); - $this->assertEquals($oSettings->getBorderTopSize(), $iVal); + $iVal = rand(1, 1000); + $oSettings->setBorderSize($iVal); + $this->assertEquals($oSettings->getBorderSize(), array($iVal, $iVal, $iVal, $iVal)); + $this->assertEquals($oSettings->getBorderBottomSize(), $iVal); + $this->assertEquals($oSettings->getBorderLeftSize(), $iVal); + $this->assertEquals($oSettings->getBorderRightSize(), $iVal); + $this->assertEquals($oSettings->getBorderTopSize(), $iVal); - $iVal = rand(1, 1000); - $oSettings->setBorderBottomSize($iVal); - $this->assertEquals($oSettings->getBorderBottomSize(), $iVal); + $iVal = rand(1, 1000); + $oSettings->setBorderBottomSize($iVal); + $this->assertEquals($oSettings->getBorderBottomSize(), $iVal); - $iVal = rand(1, 1000); - $oSettings->setBorderLeftSize($iVal); - $this->assertEquals($oSettings->getBorderLeftSize(), $iVal); + $iVal = rand(1, 1000); + $oSettings->setBorderLeftSize($iVal); + $this->assertEquals($oSettings->getBorderLeftSize(), $iVal); - $iVal = rand(1, 1000); - $oSettings->setBorderRightSize($iVal); - $this->assertEquals($oSettings->getBorderRightSize(), $iVal); + $iVal = rand(1, 1000); + $oSettings->setBorderRightSize($iVal); + $this->assertEquals($oSettings->getBorderRightSize(), $iVal); - $iVal = rand(1, 1000); - $oSettings->setBorderTopSize($iVal); - $this->assertEquals($oSettings->getBorderTopSize(), $iVal); - } + $iVal = rand(1, 1000); + $oSettings->setBorderTopSize($iVal); + $this->assertEquals($oSettings->getBorderTopSize(), $iVal); + } - public function testBorderColor(){ - // Section Settings - $oSettings = new PHPWord_Section_Settings(); + public function testBorderColor() + { + // Section Settings + $oSettings = new PHPWord_Section_Settings(); - $oSettings->setBorderColor('FF00AA'); - $this->assertEquals($oSettings->getBorderColor(), array('FF00AA', 'FF00AA', 'FF00AA', 'FF00AA')); - $this->assertEquals($oSettings->getBorderBottomColor(), 'FF00AA'); - $this->assertEquals($oSettings->getBorderLeftColor(), 'FF00AA'); - $this->assertEquals($oSettings->getBorderRightColor(), 'FF00AA'); - $this->assertEquals($oSettings->getBorderTopColor(), 'FF00AA'); + $oSettings->setBorderColor('FF00AA'); + $this->assertEquals($oSettings->getBorderColor(), array('FF00AA', 'FF00AA', 'FF00AA', 'FF00AA')); + $this->assertEquals($oSettings->getBorderBottomColor(), 'FF00AA'); + $this->assertEquals($oSettings->getBorderLeftColor(), 'FF00AA'); + $this->assertEquals($oSettings->getBorderRightColor(), 'FF00AA'); + $this->assertEquals($oSettings->getBorderTopColor(), 'FF00AA'); - $oSettings->setBorderBottomColor('BBCCDD'); - $this->assertEquals($oSettings->getBorderBottomColor(), 'BBCCDD'); + $oSettings->setBorderBottomColor('BBCCDD'); + $this->assertEquals($oSettings->getBorderBottomColor(), 'BBCCDD'); - $oSettings->setBorderLeftColor('CCDDEE'); - $this->assertEquals($oSettings->getBorderLeftColor(), 'CCDDEE'); + $oSettings->setBorderLeftColor('CCDDEE'); + $this->assertEquals($oSettings->getBorderLeftColor(), 'CCDDEE'); - $oSettings->setBorderRightColor('11EE22'); - $this->assertEquals($oSettings->getBorderRightColor(), '11EE22'); + $oSettings->setBorderRightColor('11EE22'); + $this->assertEquals($oSettings->getBorderRightColor(), '11EE22'); - $oSettings->setBorderTopColor('22FF33'); - $this->assertEquals($oSettings->getBorderTopColor(), '22FF33'); - } + $oSettings->setBorderTopColor('22FF33'); + $this->assertEquals($oSettings->getBorderTopColor(), '22FF33'); + } - public function testNumberingStart(){ - // Section Settings - $oSettings = new PHPWord_Section_Settings(); + public function testNumberingStart() + { + // Section Settings + $oSettings = new PHPWord_Section_Settings(); - $this->assertEquals($oSettings->getPageNumberingStart(), null); + $this->assertEquals($oSettings->getPageNumberingStart(), null); - $iVal = rand(1, 1000); - $oSettings->setPageNumberingStart($iVal); - $this->assertEquals($oSettings->getPageNumberingStart(), $iVal); + $iVal = rand(1, 1000); + $oSettings->setPageNumberingStart($iVal); + $this->assertEquals($oSettings->getPageNumberingStart(), $iVal); - $oSettings->setPageNumberingStart(); - $this->assertEquals($oSettings->getPageNumberingStart(), null); - } + $oSettings->setPageNumberingStart(); + $this->assertEquals($oSettings->getPageNumberingStart(), null); + } - public function testHeader(){ - // Section Settings - $oSettings = new PHPWord_Section_Settings(); + public function testHeader() + { + // Section Settings + $oSettings = new PHPWord_Section_Settings(); - $this->assertEquals($oSettings->getHeaderHeight(), 720); + $this->assertEquals($oSettings->getHeaderHeight(), 720); - $iVal = rand(1, 1000); - $oSettings->setHeaderHeight($iVal); - $this->assertEquals($oSettings->getHeaderHeight(), $iVal); + $iVal = rand(1, 1000); + $oSettings->setHeaderHeight($iVal); + $this->assertEquals($oSettings->getHeaderHeight(), $iVal); - $oSettings->setHeaderHeight(); - $this->assertEquals($oSettings->getHeaderHeight(), 720); - } + $oSettings->setHeaderHeight(); + $this->assertEquals($oSettings->getHeaderHeight(), 720); + } - public function testFooter(){ - // Section Settings - $oSettings = new PHPWord_Section_Settings(); + public function testFooter() + { + // Section Settings + $oSettings = new PHPWord_Section_Settings(); - $this->assertEquals($oSettings->getFooterHeight(), 720); + $this->assertEquals($oSettings->getFooterHeight(), 720); - $iVal = rand(1, 1000); - $oSettings->setFooterHeight($iVal); - $this->assertEquals($oSettings->getFooterHeight(), $iVal); + $iVal = rand(1, 1000); + $oSettings->setFooterHeight($iVal); + $this->assertEquals($oSettings->getFooterHeight(), $iVal); - $oSettings->setFooterHeight(); - $this->assertEquals($oSettings->getFooterHeight(), 720); - } + $oSettings->setFooterHeight(); + $this->assertEquals($oSettings->getFooterHeight(), 720); + } - public function testColumnsNum(){ - // Section Settings - $oSettings = new PHPWord_Section_Settings(); + public function testColumnsNum() + { + // Section Settings + $oSettings = new PHPWord_Section_Settings(); - // Default - $this->assertEquals($oSettings->getColsNum(), 1); + // Default + $this->assertEquals($oSettings->getColsNum(), 1); - $iVal = rand(1, 1000); - $oSettings->setColsNum($iVal); - $this->assertEquals($oSettings->getColsNum(), $iVal); + $iVal = rand(1, 1000); + $oSettings->setColsNum($iVal); + $this->assertEquals($oSettings->getColsNum(), $iVal); - $oSettings->setColsNum(); - $this->assertEquals($oSettings->getColsNum(), 1); - } + $oSettings->setColsNum(); + $this->assertEquals($oSettings->getColsNum(), 1); + } - public function testColumnsSpace(){ - // Section Settings - $oSettings = new PHPWord_Section_Settings(); + public function testColumnsSpace() + { + // Section Settings + $oSettings = new PHPWord_Section_Settings(); - // Default - $this->assertEquals($oSettings->getColsSpace(), 720); + // Default + $this->assertEquals($oSettings->getColsSpace(), 720); - $iVal = rand(1, 1000); - $this->assertInstanceOf('PHPWord_Section_Settings', $oSettings->setColsSpace($iVal)); - $this->assertEquals($oSettings->getColsSpace(), $iVal); + $iVal = rand(1, 1000); + $this->assertInstanceOf('PHPWord_Section_Settings', $oSettings->setColsSpace($iVal)); + $this->assertEquals($oSettings->getColsSpace(), $iVal); - $this->assertInstanceOf('PHPWord_Section_Settings', $oSettings->setColsSpace()); - $this->assertEquals($oSettings->getColsSpace(), 1); - } + $this->assertInstanceOf('PHPWord_Section_Settings', $oSettings->setColsSpace()); + $this->assertEquals($oSettings->getColsSpace(), 1); + } - public function testBreakType(){ - // Section Settings - $oSettings = new PHPWord_Section_Settings(); + public function testBreakType() + { + // Section Settings + $oSettings = new PHPWord_Section_Settings(); - $this->assertEquals($oSettings->getBreakType(), null); + $this->assertEquals($oSettings->getBreakType(), null); - $oSettings->setBreakType('continuous'); - $this->assertEquals($oSettings->getBreakType(), 'continuous'); + $oSettings->setBreakType('continuous'); + $this->assertEquals($oSettings->getBreakType(), 'continuous'); - $oSettings->setBreakType(); - $this->assertEquals($oSettings->getBreakType(), null); - } -} - \ No newline at end of file + $oSettings->setBreakType(); + $this->assertEquals($oSettings->getBreakType(), null); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/Table/CellTest.php b/Tests/PHPWord/Section/Table/CellTest.php index 7f8b5d27..bfd7e0d0 100644 --- a/Tests/PHPWord/Section/Table/CellTest.php +++ b/Tests/PHPWord/Section/Table/CellTest.php @@ -1,184 +1,204 @@ assertInstanceOf('PHPWord_Section_Table_Cell', $oCell); - $this->assertEquals($oCell->getWidth(), null); - } + $this->assertInstanceOf('PHPWord_Section_Table_Cell', $oCell); + $this->assertEquals($oCell->getWidth(), null); + } - public function testConstructWithStyleArray(){ - $iVal = rand(1, 1000); - $oCell = new PHPWord_Section_Table_Cell('section', $iVal, null, array('valign'=>'center')); + public function testConstructWithStyleArray() + { + $iVal = rand(1, 1000); + $oCell = new PHPWord_Section_Table_Cell('section', $iVal, null, array('valign' => 'center')); - $this->assertInstanceOf('PHPWord_Style_Cell', $oCell->getStyle()); - $this->assertEquals($oCell->getWidth(), null); - } + $this->assertInstanceOf('PHPWord_Style_Cell', $oCell->getStyle()); + $this->assertEquals($oCell->getWidth(), null); + } - public function testConstructWithStyleString(){ - $iVal = rand(1, 1000); - $oCell = new PHPWord_Section_Table_Cell('section', $iVal, null, 'cellStyle'); + public function testConstructWithStyleString() + { + $iVal = rand(1, 1000); + $oCell = new PHPWord_Section_Table_Cell('section', $iVal, null, 'cellStyle'); - $this->assertEquals($oCell->getStyle(), 'cellStyle'); - } + $this->assertEquals($oCell->getStyle(), 'cellStyle'); + } - public function testAddText(){ - $oCell = new PHPWord_Section_Table_Cell('section', 1); - $element = $oCell->addText('text'); + public function testAddText() + { + $oCell = new PHPWord_Section_Table_Cell('section', 1); + $element = $oCell->addText('text'); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Text', $element); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_Text', $element); + } - public function testAddTextNotUTF8(){ - $oCell = new PHPWord_Section_Table_Cell('section', 1); - $element = $oCell->addText(utf8_decode('ééé')); + public function testAddTextNotUTF8() + { + $oCell = new PHPWord_Section_Table_Cell('section', 1); + $element = $oCell->addText(utf8_decode('ééé')); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Text', $element); - $this->assertEquals($element->getText(), 'ééé'); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertEquals($element->getText(), 'ééé'); + } - public function testAddLink(){ - $oCell = new PHPWord_Section_Table_Cell('section', 1); - $element = $oCell->addLink('http://www.google.fr', 'Nom'); + public function testAddLink() + { + $oCell = new PHPWord_Section_Table_Cell('section', 1); + $element = $oCell->addLink('http://www.google.fr', 'Nom'); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Link', $element); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_Link', $element); + } - public function testAddTextBreak(){ - $oCell = new PHPWord_Section_Table_Cell('section', 1); - $oCell->addTextBreak(); + public function testAddTextBreak() + { + $oCell = new PHPWord_Section_Table_Cell('section', 1); + $oCell->addTextBreak(); - $this->assertCount(1, $oCell->getElements()); - } + $this->assertCount(1, $oCell->getElements()); + } - public function testAddListItem(){ - $oCell = new PHPWord_Section_Table_Cell('section', 1); - $element = $oCell->addListItem('text'); + public function testAddListItem() + { + $oCell = new PHPWord_Section_Table_Cell('section', 1); + $element = $oCell->addListItem('text'); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_ListItem', $element); - $this->assertEquals($element->getTextObject()->getText(), 'text'); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_ListItem', $element); + $this->assertEquals($element->getTextObject()->getText(), 'text'); + } - public function testAddListItemNotUTF8(){ - $oCell = new PHPWord_Section_Table_Cell('section', 1); - $element = $oCell->addListItem(utf8_decode('ééé')); + public function testAddListItemNotUTF8() + { + $oCell = new PHPWord_Section_Table_Cell('section', 1); + $element = $oCell->addListItem(utf8_decode('ééé')); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_ListItem', $element); - $this->assertEquals($element->getTextObject()->getText(), 'ééé'); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_ListItem', $element); + $this->assertEquals($element->getTextObject()->getText(), 'ééé'); + } - public function testAddImageSection(){ - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') - ); - $oCell = new PHPWord_Section_Table_Cell('section', 1); - $element = $oCell->addImage($src); + public function testAddImageSection() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + ); + $oCell = new PHPWord_Section_Table_Cell('section', 1); + $element = $oCell->addImage($src); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Image', $element); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_Image', $element); + } - public function testAddImageHeader(){ - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') - ); - $oCell = new PHPWord_Section_Table_Cell('header', 1); - $element = $oCell->addImage($src); + public function testAddImageHeader() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + ); + $oCell = new PHPWord_Section_Table_Cell('header', 1); + $element = $oCell->addImage($src); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Image', $element); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_Image', $element); + } - public function testAddImageFooter(){ - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') - ); - $oCell = new PHPWord_Section_Table_Cell('footer', 1); - $element = $oCell->addImage($src); + public function testAddImageFooter() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + ); + $oCell = new PHPWord_Section_Table_Cell('footer', 1); + $element = $oCell->addImage($src); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Image', $element); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_Image', $element); + } - 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'); + 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'); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); + } - 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'); + 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'); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); + } - 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'); + 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'); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); + } - public function testAddObjectXLS(){ - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') - ); - $oCell = new PHPWord_Section_Table_Cell('section', 1); - $element = $oCell->addObject($src); + public function testAddObjectXLS() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + ); + $oCell = new PHPWord_Section_Table_Cell('section', 1); + $element = $oCell->addObject($src); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Object', $element); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_Object', $element); + } - public function testAddPreserveText(){ - $oCell = new PHPWord_Section_Table_Cell('header', 1); - $element = $oCell->addPreserveText('text'); + public function testAddPreserveText() + { + $oCell = new PHPWord_Section_Table_Cell('header', 1); + $element = $oCell->addPreserveText('text'); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); + } - public function testAddPreserveTextNotUTF8(){ - $oCell = new PHPWord_Section_Table_Cell('header', 1); - $element = $oCell->addPreserveText(utf8_decode('ééé')); + public function testAddPreserveTextNotUTF8() + { + $oCell = new PHPWord_Section_Table_Cell('header', 1); + $element = $oCell->addPreserveText(utf8_decode('ééé')); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); - $this->assertEquals($element->getText(), 'ééé'); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); + $this->assertEquals($element->getText(), 'ééé'); + } - public function testCreateTextRun(){ - $oCell = new PHPWord_Section_Table_Cell('section', 1); - $element = $oCell->createTextRun(); + public function testCreateTextRun() + { + $oCell = new PHPWord_Section_Table_Cell('section', 1); + $element = $oCell->createTextRun(); - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_TextRun', $element); - } + $this->assertCount(1, $oCell->getElements()); + $this->assertInstanceOf('PHPWord_Section_TextRun', $element); + } - public function testGetElements(){ - $oCell = new PHPWord_Section_Table_Cell('section', 1); + public function testGetElements() + { + $oCell = new PHPWord_Section_Table_Cell('section', 1); - $this->assertInternalType('array', $oCell->getElements()); - } -} - \ No newline at end of file + $this->assertInternalType('array', $oCell->getElements()); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/Table/RowTest.php b/Tests/PHPWord/Section/Table/RowTest.php index 1cf5758d..849abbac 100644 --- a/Tests/PHPWord/Section/Table/RowTest.php +++ b/Tests/PHPWord/Section/Table/RowTest.php @@ -1,35 +1,39 @@ assertInstanceOf('PHPWord_Section_Table_Row', $oRow); - $this->assertEquals($oRow->getHeight(), null); - $this->assertInternalType('array', $oRow->getCells()); - $this->assertCount(0, $oRow->getCells()); - $this->assertInstanceOf('PHPWord_Style_Row', $oRow->getStyle()); - } - 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')); + $this->assertInstanceOf('PHPWord_Section_Table_Row', $oRow); + $this->assertEquals($oRow->getHeight(), null); + $this->assertInternalType('array', $oRow->getCells()); + $this->assertCount(0, $oRow->getCells()); + $this->assertInstanceOf('PHPWord_Style_Row', $oRow->getStyle()); + } - $this->assertEquals($oRow->getHeight(), $iVal2); - $this->assertInstanceOf('PHPWord_Style_Row', $oRow->getStyle()); - } + 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')); - public function testAddCell(){ - $oRow = new PHPWord_Section_Table_Row('section', 1); - $element = $oRow->addCell(); + $this->assertEquals($oRow->getHeight(), $iVal2); + $this->assertInstanceOf('PHPWord_Style_Row', $oRow->getStyle()); + } - $this->assertInstanceOf('PHPWord_Section_Table_Cell', $element); - $this->assertCount(1, $oRow->getCells()); - } -} - \ No newline at end of file + public function testAddCell() + { + $oRow = new PHPWord_Section_Table_Row('section', 1); + $element = $oRow->addCell(); + + $this->assertInstanceOf('PHPWord_Section_Table_Cell', $element); + $this->assertCount(1, $oRow->getCells()); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/TableTest.php b/Tests/PHPWord/Section/TableTest.php index f481b4b8..f207d426 100644 --- a/Tests/PHPWord/Section/TableTest.php +++ b/Tests/PHPWord/Section/TableTest.php @@ -1,46 +1,57 @@ assertInstanceOf('PHPWord_Section_Table', $oTable); - $this->assertEquals($oTable->getStyle(), null); - $this->assertEquals($oTable->getWidth(), null); - $this->assertEquals($oTable->getRows(), array()); - $this->assertCount(0, $oTable->getRows()); - } - public function testStyleText() { - $oTable = new PHPWord_Section_Table('section', 1, 'tableStyle'); + $this->assertInstanceOf('PHPWord_Section_Table', $oTable); + $this->assertEquals($oTable->getStyle(), null); + $this->assertEquals($oTable->getWidth(), null); + $this->assertEquals($oTable->getRows(), array()); + $this->assertCount(0, $oTable->getRows()); + } - $this->assertEquals($oTable->getStyle(), 'tableStyle'); - } - public function testStyleArray() { - $oTable = new PHPWord_Section_Table('section', 1, array('borderSize'=>6, 'borderColor'=>'006699', 'cellMargin'=>80)); + public function testStyleText() + { + $oTable = new PHPWord_Section_Table('section', 1, 'tableStyle'); - $this->assertInstanceOf('PHPWord_Style_Table', $oTable->getStyle()); - } - 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() { - $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() { - $oTable = new PHPWord_Section_Table('section', 1); - $oTable->addRow(); - $element = $oTable->addCell(); - $this->assertInstanceOf('PHPWord_Section_Table_Cell', $element); - } -} - \ No newline at end of file + $this->assertEquals($oTable->getStyle(), 'tableStyle'); + } + + 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() + { + $oTable = new PHPWord_Section_Table('section', 1); + $iVal = rand(1, 1000); + $oTable->setWidth($iVal); + $this->assertEquals($oTable->getWidth(), $iVal); + } + + 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() + { + $oTable = new PHPWord_Section_Table('section', 1); + $oTable->addRow(); + $element = $oTable->addCell(); + $this->assertInstanceOf('PHPWord_Section_Table_Cell', $element); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/TextBreakTest.php b/Tests/PHPWord/Section/TextBreakTest.php index a3f8d031..86e9ac48 100644 --- a/Tests/PHPWord/Section/TextBreakTest.php +++ b/Tests/PHPWord/Section/TextBreakTest.php @@ -1,18 +1,19 @@ assertInstanceOf('PHPWord_Section_TextBreak', $oTextBreak); - } -} - \ No newline at end of file + $this->assertInstanceOf('PHPWord_Section_TextBreak', $oTextBreak); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/TextRunTest.php b/Tests/PHPWord/Section/TextRunTest.php index cbaf3acd..0ea9d701 100644 --- a/Tests/PHPWord/Section/TextRunTest.php +++ b/Tests/PHPWord/Section/TextRunTest.php @@ -1,81 +1,98 @@ assertInstanceOf('PHPWord_Section_TextRun', $oTextRun); - $this->assertCount(0, $oTextRun->getElements()); - $this->assertEquals($oTextRun->getParagraphStyle(), null); - } - public function testConstructString() { - $oTextRun = new PHPWord_Section_TextRun('pStyle'); + $this->assertInstanceOf('PHPWord_Section_TextRun', $oTextRun); + $this->assertCount(0, $oTextRun->getElements()); + $this->assertEquals($oTextRun->getParagraphStyle(), null); + } - $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 testConstructString() + { + $oTextRun = new PHPWord_Section_TextRun('pStyle'); - $this->assertInstanceOf('PHPWord_Section_TextRun', $oTextRun); - $this->assertCount(0, $oTextRun->getElements()); - $this->assertInstanceOf('PHPWord_Style_Paragraph', $oTextRun->getParagraphStyle()); - } - public function testAddText() { - $oTextRun = new PHPWord_Section_TextRun(); - $element = $oTextRun->addText('text'); + $this->assertInstanceOf('PHPWord_Section_TextRun', $oTextRun); + $this->assertCount(0, $oTextRun->getElements()); + $this->assertEquals($oTextRun->getParagraphStyle(), 'pStyle'); + } - $this->assertInstanceOf('PHPWord_Section_Text', $element); - $this->assertCount(1, $oTextRun->getElements()); - $this->assertEquals($element->getText(), 'text'); - } - public function testAddTextNotUTF8() { - $oTextRun = new PHPWord_Section_TextRun(); - $element = $oTextRun->addText(utf8_decode('ééé')); + public function testConstructArray() + { + $oTextRun = new PHPWord_Section_TextRun(array('spacing' => 100)); - $this->assertInstanceOf('PHPWord_Section_Text', $element); - $this->assertCount(1, $oTextRun->getElements()); - $this->assertEquals($element->getText(), 'ééé'); - } - public function testAddLink() { - $oTextRun = new PHPWord_Section_TextRun(); - $element = $oTextRun->addLink('http://www.google.fr'); + $this->assertInstanceOf('PHPWord_Section_TextRun', $oTextRun); + $this->assertCount(0, $oTextRun->getElements()); + $this->assertInstanceOf('PHPWord_Style_Paragraph', $oTextRun->getParagraphStyle()); + } - $this->assertInstanceOf('PHPWord_Section_Link', $element); - $this->assertCount(1, $oTextRun->getElements()); - $this->assertEquals($element->getLinkSrc(), 'http://www.google.fr'); - } - public function testAddLinkWithName() { - $oTextRun = new PHPWord_Section_TextRun(); - $element = $oTextRun->addLink('http://www.google.fr', utf8_decode('ééé')); + public function testAddText() + { + $oTextRun = new PHPWord_Section_TextRun(); + $element = $oTextRun->addText('text'); - $this->assertInstanceOf('PHPWord_Section_Link', $element); - $this->assertCount(1, $oTextRun->getElements()); - $this->assertEquals($element->getLinkSrc(), 'http://www.google.fr'); - $this->assertEquals($element->getLinkName(), 'ééé'); - } - public function testAddImage() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') - ); - $oTextRun = new PHPWord_Section_TextRun(); - $element = $oTextRun->addImage($src); + $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertCount(1, $oTextRun->getElements()); + $this->assertEquals($element->getText(), 'text'); + } - $this->assertInstanceOf('PHPWord_Section_Image', $element); - $this->assertCount(1, $oTextRun->getElements()); - } - public function testCreateFootnote() { - $oTextRun = new PHPWord_Section_TextRun(); - $element = $oTextRun->createFootnote(); + public function testAddTextNotUTF8() + { + $oTextRun = new PHPWord_Section_TextRun(); + $element = $oTextRun->addText(utf8_decode('ééé')); - $this->assertInstanceOf('PHPWord_Section_Footnote', $element); - $this->assertCount(1, $oTextRun->getElements()); - } -} - \ No newline at end of file + $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertCount(1, $oTextRun->getElements()); + $this->assertEquals($element->getText(), 'ééé'); + } + + public function testAddLink() + { + $oTextRun = new PHPWord_Section_TextRun(); + $element = $oTextRun->addLink('http://www.google.fr'); + + $this->assertInstanceOf('PHPWord_Section_Link', $element); + $this->assertCount(1, $oTextRun->getElements()); + $this->assertEquals($element->getLinkSrc(), 'http://www.google.fr'); + } + + public function testAddLinkWithName() + { + $oTextRun = new PHPWord_Section_TextRun(); + $element = $oTextRun->addLink('http://www.google.fr', utf8_decode('ééé')); + + $this->assertInstanceOf('PHPWord_Section_Link', $element); + $this->assertCount(1, $oTextRun->getElements()); + $this->assertEquals($element->getLinkSrc(), 'http://www.google.fr'); + $this->assertEquals($element->getLinkName(), 'ééé'); + } + + public function testAddImage() + { + $src = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + ); + $oTextRun = new PHPWord_Section_TextRun(); + $element = $oTextRun->addImage($src); + + $this->assertInstanceOf('PHPWord_Section_Image', $element); + $this->assertCount(1, $oTextRun->getElements()); + } + + public function testCreateFootnote() + { + $oTextRun = new PHPWord_Section_TextRun(); + $element = $oTextRun->createFootnote(); + + $this->assertInstanceOf('PHPWord_Section_Footnote', $element); + $this->assertCount(1, $oTextRun->getElements()); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/TextTest.php b/Tests/PHPWord/Section/TextTest.php index 08812a39..6fe0cf38 100644 --- a/Tests/PHPWord/Section/TextTest.php +++ b/Tests/PHPWord/Section/TextTest.php @@ -1,36 +1,43 @@ assertInstanceOf('PHPWord_Section_Text', $oText); - $this->assertEquals($oText->getText(), null); - $this->assertEquals($oText->getFontStyle(), null); - $this->assertEquals($oText->getParagraphStyle(), null); - } - public function testText() { - $oText = new PHPWord_Section_Text('text'); + $this->assertInstanceOf('PHPWord_Section_Text', $oText); + $this->assertEquals($oText->getText(), null); + $this->assertEquals($oText->getFontStyle(), null); + $this->assertEquals($oText->getParagraphStyle(), null); + } - $this->assertEquals($oText->getText(), 'text'); - } - public function testFont() { - $oText = new PHPWord_Section_Text('text', 'fontStyle'); - $this->assertEquals($oText->getFontStyle(), 'fontStyle'); + public function testText() + { + $oText = new PHPWord_Section_Text('text'); - $oText->setFontStyle(array('bold'=>true, 'italic'=>true, 'size'=>16)); - $this->assertInstanceOf('PHPWord_Style_Font', $oText->getFontStyle()); - } - public function testParagraph() { - $oText = new PHPWord_Section_Text('text', 'fontStyle', 'paragraphStyle'); - $this->assertEquals($oText->getParagraphStyle(), 'paragraphStyle'); + $this->assertEquals($oText->getText(), 'text'); + } - $oText->setParagraphStyle(array('align'=>'center', 'spaceAfter'=>100)); - $this->assertInstanceOf('PHPWord_Style_Paragraph', $oText->getParagraphStyle()); - } -} - \ No newline at end of file + public function testFont() + { + $oText = new PHPWord_Section_Text('text', 'fontStyle'); + $this->assertEquals($oText->getFontStyle(), 'fontStyle'); + + $oText->setFontStyle(array('bold' => true, 'italic' => true, 'size' => 16)); + $this->assertInstanceOf('PHPWord_Style_Font', $oText->getFontStyle()); + } + + public function testParagraph() + { + $oText = new PHPWord_Section_Text('text', 'fontStyle', 'paragraphStyle'); + $this->assertEquals($oText->getParagraphStyle(), 'paragraphStyle'); + + $oText->setParagraphStyle(array('align' => 'center', 'spaceAfter' => 100)); + $this->assertInstanceOf('PHPWord_Style_Paragraph', $oText->getParagraphStyle()); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/TitleTest.php b/Tests/PHPWord/Section/TitleTest.php index a13ddd06..c595ab97 100644 --- a/Tests/PHPWord/Section/TitleTest.php +++ b/Tests/PHPWord/Section/TitleTest.php @@ -1,39 +1,48 @@ assertInstanceOf('PHPWord_Section_Title', $oTitle); - $this->assertEquals($oTitle->getText(), 'text'); - } - public function testStyleNull() { - $oTitle = new PHPWord_Section_Title('text'); + $this->assertInstanceOf('PHPWord_Section_Title', $oTitle); + $this->assertEquals($oTitle->getText(), 'text'); + } - $this->assertEquals($oTitle->getStyle(), null); - } - public function testStyleNotNull() { - $oTitle = new PHPWord_Section_Title('text', 1, 'style'); + public function testStyleNull() + { + $oTitle = new PHPWord_Section_Title('text'); - $this->assertEquals($oTitle->getStyle(), 'style'); - } - public function testAnchor() { - $oTitle = new PHPWord_Section_Title('text'); + $this->assertEquals($oTitle->getStyle(), null); + } - $iVal = rand(1, 1000); - $oTitle->setAnchor($iVal); - $this->assertEquals($oTitle->getAnchor(), $iVal); - } - public function testBookmarkID() { - $oTitle = new PHPWord_Section_Title('text'); + public function testStyleNotNull() + { + $oTitle = new PHPWord_Section_Title('text', 1, 'style'); - $iVal = rand(1, 1000); - $oTitle->setBookmarkId($iVal); - $this->assertEquals($oTitle->getBookmarkId(), $iVal); - } -} - \ No newline at end of file + $this->assertEquals($oTitle->getStyle(), 'style'); + } + + public function testAnchor() + { + $oTitle = new PHPWord_Section_Title('text'); + + $iVal = rand(1, 1000); + $oTitle->setAnchor($iVal); + $this->assertEquals($oTitle->getAnchor(), $iVal); + } + + public function testBookmarkID() + { + $oTitle = new PHPWord_Section_Title('text'); + + $iVal = rand(1, 1000); + $oTitle->setBookmarkId($iVal); + $this->assertEquals($oTitle->getBookmarkId(), $iVal); + } +} \ No newline at end of file