Skip to content

Commit a6671c2

Browse files
committed
Reformatted tests to PSR-2 standards
1 parent 9966508 commit a6671c2

18 files changed

+1321
-1173
lines changed
Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
<?php
2-
namespace PHPWord\Tests;
2+
namespace PHPWord\Tests\Section\Footer;
33

44
use PHPUnit_Framework_TestCase;
55
use PHPWord_Section_Footer_PreserveText;
66

7-
class PHPWord_Section_Footer_PreserveTextTest extends \PHPUnit_Framework_TestCase {
8-
public function testConstruct(){
9-
$oPreserveText = new PHPWord_Section_Footer_PreserveText();
7+
class PreserveTextTest extends \PHPUnit_Framework_TestCase
8+
{
9+
public function testConstruct()
10+
{
11+
$oPreserveText = new PHPWord_Section_Footer_PreserveText();
1012

11-
$this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $oPreserveText);
12-
$this->assertEquals($oPreserveText->getText(), null);
13-
$this->assertEquals($oPreserveText->getFontStyle(), null);
14-
$this->assertEquals($oPreserveText->getParagraphStyle(), null);
15-
}
13+
$this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $oPreserveText);
14+
$this->assertEquals($oPreserveText->getText(), null);
15+
$this->assertEquals($oPreserveText->getFontStyle(), null);
16+
$this->assertEquals($oPreserveText->getParagraphStyle(), null);
17+
}
1618

17-
public function testConstructWithString(){
18-
$oPreserveText = new PHPWord_Section_Footer_PreserveText('text', 'styleFont', 'styleParagraph');
19-
$this->assertEquals($oPreserveText->getText(), 'text');
20-
$this->assertEquals($oPreserveText->getFontStyle(), 'styleFont');
21-
$this->assertEquals($oPreserveText->getParagraphStyle(), 'styleParagraph');
22-
}
19+
public function testConstructWithString()
20+
{
21+
$oPreserveText = new PHPWord_Section_Footer_PreserveText('text', 'styleFont', 'styleParagraph');
22+
$this->assertEquals($oPreserveText->getText(), 'text');
23+
$this->assertEquals($oPreserveText->getFontStyle(), 'styleFont');
24+
$this->assertEquals($oPreserveText->getParagraphStyle(), 'styleParagraph');
25+
}
2326

24-
public function testConstructWithArray(){
25-
$oPreserveText = new PHPWord_Section_Footer_PreserveText('text', array('align'=>'center'), array('marginLeft'=>600, 'marginRight'=>600, 'marginTop'=>600, 'marginBottom'=>600));
26-
$this->assertInstanceOf('PHPWord_Style_Font', $oPreserveText->getFontStyle());
27-
$this->assertInstanceOf('PHPWord_Style_Paragraph', $oPreserveText->getParagraphStyle());
28-
}
29-
}
30-
27+
public function testConstructWithArray()
28+
{
29+
$oPreserveText = new PHPWord_Section_Footer_PreserveText('text', array('align' => 'center'), array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600));
30+
$this->assertInstanceOf('PHPWord_Style_Font', $oPreserveText->getFontStyle());
31+
$this->assertInstanceOf('PHPWord_Style_Paragraph', $oPreserveText->getParagraphStyle());
32+
}
33+
}

Tests/PHPWord/Section/FooterTest.php

Lines changed: 116 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,121 @@
11
<?php
2-
namespace PHPWord\Tests;
2+
namespace PHPWord\Tests\Section;
33

44
use PHPUnit_Framework_TestCase;
55
use PHPWord_Section_Footer;
66

7-
class PHPWord_Section_FooterTest extends \PHPUnit_Framework_TestCase {
8-
9-
public function testConstruct(){
10-
$iVal = rand(1, 1000);
11-
$oFooter = new PHPWord_Section_Footer($iVal);
12-
13-
$this->assertInstanceOf('PHPWord_Section_Footer', $oFooter);
14-
$this->assertEquals($oFooter->getFooterCount(), $iVal);
15-
}
16-
17-
public function testRelationID(){
18-
$oFooter = new PHPWord_Section_Footer(0);
19-
20-
$iVal = rand(1, 1000);
21-
$oFooter->setRelationId($iVal);
22-
$this->assertEquals($oFooter->getRelationId(), $iVal);
23-
}
24-
25-
public function testAddText(){
26-
$oFooter = new PHPWord_Section_Footer(1);
27-
$element = $oFooter->addText('text');
28-
29-
$this->assertCount(1, $oFooter->getElements());
30-
$this->assertInstanceOf('PHPWord_Section_Text', $element);
31-
32-
}
33-
34-
public function testAddTextNotUTF8(){
35-
$oFooter = new PHPWord_Section_Footer(1);
36-
$element = $oFooter->addText(utf8_decode('ééé'));
37-
38-
$this->assertCount(1, $oFooter->getElements());
39-
$this->assertInstanceOf('PHPWord_Section_Text', $element);
40-
$this->assertEquals($element->getText(), 'ééé');
41-
}
42-
43-
public function testAddTextBreak(){
44-
$oFooter = new PHPWord_Section_Footer(1);
45-
$iVal = rand(1, 1000);
46-
$oFooter->addTextBreak($iVal);
47-
48-
$this->assertCount($iVal, $oFooter->getElements());
49-
}
50-
51-
public function testCreateTextRun(){
52-
$oFooter = new PHPWord_Section_Footer(1);
53-
$element = $oFooter->createTextRun();
54-
55-
$this->assertCount(1, $oFooter->getElements());
56-
$this->assertInstanceOf('PHPWord_Section_TextRun', $element);
57-
}
58-
59-
public function testAddTable(){
60-
$oFooter = new PHPWord_Section_Footer(1);
61-
$element = $oFooter->addTable();
62-
63-
$this->assertCount(1, $oFooter->getElements());
64-
$this->assertInstanceOf('PHPWord_Section_Table', $element);
65-
}
66-
67-
public function testAddImage(){
68-
$src = \join(
69-
\DIRECTORY_SEPARATOR,
70-
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
71-
);
72-
$oFooter = new PHPWord_Section_Footer(1);
73-
$element = $oFooter->addImage($src);
74-
75-
$this->assertCount(1, $oFooter->getElements());
76-
$this->assertInstanceOf('PHPWord_Section_Image', $element);
77-
}
78-
79-
public function testAddMemoryImage(){
80-
$oFooter = new PHPWord_Section_Footer(1);
81-
$element = $oFooter->addMemoryImage('https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png');
82-
83-
$this->assertCount(1, $oFooter->getElements());
84-
$this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
85-
}
86-
87-
public function testAddPreserveText(){
88-
$oFooter = new PHPWord_Section_Footer(1);
89-
$element = $oFooter->addPreserveText('text');
90-
91-
$this->assertCount(1, $oFooter->getElements());
92-
$this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
93-
}
94-
95-
public function testAddPreserveTextNotUTF8(){
96-
$oFooter = new PHPWord_Section_Footer(1);
97-
$element = $oFooter->addPreserveText(utf8_decode('ééé'));
98-
99-
$this->assertCount(1, $oFooter->getElements());
100-
$this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
101-
$this->assertEquals($element->getText(), 'ééé');
102-
}
103-
104-
public function testGetElements(){
105-
$oFooter = new PHPWord_Section_Footer(1);
106-
107-
$this->assertInternalType('array', $oFooter->getElements());
108-
}
109-
}
110-
7+
class FooterTest extends \PHPUnit_Framework_TestCase
8+
{
9+
public function testConstruct()
10+
{
11+
$iVal = rand(1, 1000);
12+
$oFooter = new PHPWord_Section_Footer($iVal);
13+
14+
$this->assertInstanceOf('PHPWord_Section_Footer', $oFooter);
15+
$this->assertEquals($oFooter->getFooterCount(), $iVal);
16+
}
17+
18+
public function testRelationID()
19+
{
20+
$oFooter = new PHPWord_Section_Footer(0);
21+
22+
$iVal = rand(1, 1000);
23+
$oFooter->setRelationId($iVal);
24+
$this->assertEquals($oFooter->getRelationId(), $iVal);
25+
}
26+
27+
public function testAddText()
28+
{
29+
$oFooter = new PHPWord_Section_Footer(1);
30+
$element = $oFooter->addText('text');
31+
32+
$this->assertCount(1, $oFooter->getElements());
33+
$this->assertInstanceOf('PHPWord_Section_Text', $element);
34+
35+
}
36+
37+
public function testAddTextNotUTF8()
38+
{
39+
$oFooter = new PHPWord_Section_Footer(1);
40+
$element = $oFooter->addText(utf8_decode('ééé'));
41+
42+
$this->assertCount(1, $oFooter->getElements());
43+
$this->assertInstanceOf('PHPWord_Section_Text', $element);
44+
$this->assertEquals($element->getText(), 'ééé');
45+
}
46+
47+
public function testAddTextBreak()
48+
{
49+
$oFooter = new PHPWord_Section_Footer(1);
50+
$iVal = rand(1, 1000);
51+
$oFooter->addTextBreak($iVal);
52+
53+
$this->assertCount($iVal, $oFooter->getElements());
54+
}
55+
56+
public function testCreateTextRun()
57+
{
58+
$oFooter = new PHPWord_Section_Footer(1);
59+
$element = $oFooter->createTextRun();
60+
61+
$this->assertCount(1, $oFooter->getElements());
62+
$this->assertInstanceOf('PHPWord_Section_TextRun', $element);
63+
}
64+
65+
public function testAddTable()
66+
{
67+
$oFooter = new PHPWord_Section_Footer(1);
68+
$element = $oFooter->addTable();
69+
70+
$this->assertCount(1, $oFooter->getElements());
71+
$this->assertInstanceOf('PHPWord_Section_Table', $element);
72+
}
73+
74+
public function testAddImage()
75+
{
76+
$src = \join(
77+
\DIRECTORY_SEPARATOR,
78+
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
79+
);
80+
$oFooter = new PHPWord_Section_Footer(1);
81+
$element = $oFooter->addImage($src);
82+
83+
$this->assertCount(1, $oFooter->getElements());
84+
$this->assertInstanceOf('PHPWord_Section_Image', $element);
85+
}
86+
87+
public function testAddMemoryImage()
88+
{
89+
$oFooter = new PHPWord_Section_Footer(1);
90+
$element = $oFooter->addMemoryImage('https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png');
91+
92+
$this->assertCount(1, $oFooter->getElements());
93+
$this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
94+
}
95+
96+
public function testAddPreserveText()
97+
{
98+
$oFooter = new PHPWord_Section_Footer(1);
99+
$element = $oFooter->addPreserveText('text');
100+
101+
$this->assertCount(1, $oFooter->getElements());
102+
$this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
103+
}
104+
105+
public function testAddPreserveTextNotUTF8()
106+
{
107+
$oFooter = new PHPWord_Section_Footer(1);
108+
$element = $oFooter->addPreserveText(utf8_decode('ééé'));
109+
110+
$this->assertCount(1, $oFooter->getElements());
111+
$this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
112+
$this->assertEquals($element->getText(), 'ééé');
113+
}
114+
115+
public function testGetElements()
116+
{
117+
$oFooter = new PHPWord_Section_Footer(1);
118+
119+
$this->assertInternalType('array', $oFooter->getElements());
120+
}
121+
}
Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,64 @@
11
<?php
2-
namespace PHPWord\Tests;
2+
namespace PHPWord\Tests\Section;
33

44
use PHPUnit_Framework_TestCase;
55
use PHPWord_Section_Footnote;
66

7-
class PHPWord_Section_FootnoteTest extends \PHPUnit_Framework_TestCase {
7+
class FootnoteTest extends \PHPUnit_Framework_TestCase
8+
{
9+
public function testConstruct()
10+
{
11+
$oFootnote = new PHPWord_Section_Footnote();
812

9-
public function testConstruct(){
10-
$oFootnote = new PHPWord_Section_Footnote();
13+
$this->assertInstanceOf('PHPWord_Section_Footnote', $oFootnote);
14+
$this->assertCount(0, $oFootnote->getElements());
15+
$this->assertEquals($oFootnote->getParagraphStyle(), null);
16+
}
1117

12-
$this->assertInstanceOf('PHPWord_Section_Footnote', $oFootnote);
13-
$this->assertCount(0, $oFootnote->getElements());
14-
$this->assertEquals($oFootnote->getParagraphStyle(), null);
15-
}
18+
public function testConstructString()
19+
{
20+
$oFootnote = new PHPWord_Section_Footnote('pStyle');
1621

17-
public function testConstructString(){
18-
$oFootnote = new PHPWord_Section_Footnote('pStyle');
22+
$this->assertEquals($oFootnote->getParagraphStyle(), 'pStyle');
23+
}
1924

20-
$this->assertEquals($oFootnote->getParagraphStyle(), 'pStyle');
21-
}
25+
public function testConstructArray()
26+
{
27+
$oFootnote = new PHPWord_Section_Footnote(array('spacing' => 100));
2228

23-
public function testConstructArray(){
24-
$oFootnote = new PHPWord_Section_Footnote(array('spacing' => 100));
29+
$this->assertInstanceOf('PHPWord_Style_Paragraph', $oFootnote->getParagraphStyle());
30+
}
2531

26-
$this->assertInstanceOf('PHPWord_Style_Paragraph', $oFootnote->getParagraphStyle());
27-
}
32+
public function testAddText()
33+
{
34+
$oFootnote = new PHPWord_Section_Footnote();
35+
$element = $oFootnote->addText('text');
2836

29-
public function testAddText(){
30-
$oFootnote = new PHPWord_Section_Footnote();
31-
$element = $oFootnote->addText('text');
37+
$this->assertCount(1, $oFootnote->getElements());
38+
$this->assertInstanceOf('PHPWord_Section_Text', $element);
39+
}
3240

33-
$this->assertCount(1, $oFootnote->getElements());
34-
$this->assertInstanceOf('PHPWord_Section_Text', $element);
35-
}
41+
public function testAddLink()
42+
{
43+
$oFootnote = new PHPWord_Section_Footnote();
44+
$element = $oFootnote->addLink('http://www.google.fr');
3645

37-
public function testAddLink(){
38-
$oFootnote = new PHPWord_Section_Footnote();
39-
$element = $oFootnote->addLink('http://www.google.fr');
46+
$this->assertCount(1, $oFootnote->getElements());
47+
$this->assertInstanceOf('PHPWord_Section_Link', $element);
48+
}
4049

41-
$this->assertCount(1, $oFootnote->getElements());
42-
$this->assertInstanceOf('PHPWord_Section_Link', $element);
43-
}
50+
public function testReferenceId()
51+
{
52+
$oFootnote = new PHPWord_Section_Footnote();
4453

45-
public function testReferenceId(){
46-
$oFootnote = new PHPWord_Section_Footnote();
54+
$iVal = rand(1, 1000);
55+
$oFootnote->setReferenceId($iVal);
56+
$this->assertEquals($oFootnote->getReferenceId(), $iVal);
57+
}
4758

48-
$iVal = rand(1, 1000);
49-
$oFootnote->setReferenceId($iVal);
50-
$this->assertEquals($oFootnote->getReferenceId(), $iVal);
51-
}
52-
53-
public function testGetElements(){
54-
$oFootnote = new PHPWord_Section_Footnote();
55-
$this->assertInternalType('array', $oFootnote->getElements());
56-
}
57-
}
58-
59+
public function testGetElements()
60+
{
61+
$oFootnote = new PHPWord_Section_Footnote();
62+
$this->assertInternalType('array', $oFootnote->getElements());
63+
}
64+
}

0 commit comments

Comments
 (0)