Skip to content

Commit d1022a9

Browse files
committed
QA: PHPMD fixes for tests; Some adjustment for Travis build
1 parent 3d19256 commit d1022a9

16 files changed

+27
-27
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ script:
5252
## PHP Copy/Paste Detector
5353
- phpcpd src/ tests/ --verbose
5454
## PHP Mess Detector
55-
- phpmd src/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php
55+
- phpmd src/,tests/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php
5656
## PHPLOC
5757
#- php phploc.phar src/
5858
## PHPUnit
5959
- phpunit -c ./ --coverage-text --coverage-html ./build/coverage
6060
## PHPDocumentor
61-
- vendor/bin/phpdoc.php -d ./src -t ./build/docs
61+
- vendor/bin/phpdoc.php -d ./src -t ./build/docs -i ./src/PhpWord/Shared/PCLZip/
6262

6363
after_script:
6464
## PHPDocumentor

.travis_shell_after_success.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" ==
3131

3232
echo "--DEBUG : Git"
3333
git add -f .
34-
git commit -m "PHPDocumentor (Travis Build : $TRAVIS_BUILD_NUMBER - Branch : $TRAVIS_BRANCH)"
34+
git commit -m "PHPDocumentor (Travis Build: $TRAVIS_BUILD_NUMBER - Branch: $TRAVIS_BRANCH)"
3535
git push -fq origin gh-pages > /dev/null
3636

3737
echo -e "Published PHPDoc to gh-pages.\n"

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers
44

55
## 0.11.0 - Not yet released
66

7-
PHPWord license is changed from LGPL 2.1 to LGPL 3 in this release.
7+
This release changed PHPWord license from LGPL 2.1 to LGPL 3.
88

99
### Features
1010

phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@
2121
</exclude>
2222
</whitelist>
2323
</filter>
24+
<logging>
25+
<log type="coverage-html" target="./build/coverage" charset="UTF-8" highlight="true" />
26+
</logging>
2427
</phpunit>

tests/PhpWord/Tests/Element/CellTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public function testAddObjectException()
219219
{
220220
$src = __DIR__ . "/../_files/xsl/passthrough.xsl";
221221
$oCell = new Cell('section', 1);
222-
$element = $oCell->addObject($src);
222+
$oCell->addObject($src);
223223
}
224224

225225
/**
@@ -255,7 +255,7 @@ public function testAddPreserveTextNotUTF8()
255255
public function testAddPreserveTextException()
256256
{
257257
$oCell = new Cell('section', 1);
258-
$element = $oCell->addPreserveText('text');
258+
$oCell->addPreserveText('text');
259259
}
260260

261261
/**

tests/PhpWord/Tests/Element/ImageTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public function testInvalidImageLocal()
107107
public function testInvalidImagePhp()
108108
{
109109
$object = new Image('test.php');
110+
$object->getSource();
110111
}
111112

112113
/**
@@ -117,6 +118,7 @@ public function testInvalidImagePhp()
117118
public function testUnsupportedImage()
118119
{
119120
$object = new Image('http://samples.libav.org/image-samples/RACECAR.BMP');
121+
$object->getSource();
120122
}
121123

122124
/**

tests/PhpWord/Tests/Element/ObjectTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,14 @@ public function testConstructWithSupportedFiles()
3434

3535
/**
3636
* Create new instance with non-supported files
37+
*
38+
* @expectedException \PhpOffice\PhpWord\Exception\InvalidObjectException
3739
*/
3840
public function testConstructWithNotSupportedFiles()
3941
{
4042
$src = __DIR__ . "/../_files/xsl/passthrough.xsl";
4143
$oObject = new Object($src);
42-
43-
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Object', $oObject);
44-
$this->assertEquals($oObject->getSource(), null);
45-
$this->assertEquals($oObject->getStyle(), null);
44+
$oObject->getSource();
4645
}
4746

4847
/**

tests/PhpWord/Tests/Element/SectionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testAddElements()
7676
{
7777
$objectSource = __DIR__ . "/../_files/documents/reader.docx";
7878
$imageSource = __DIR__ . "/../_files/images/PhpWord.png";
79-
$imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif';
79+
// $imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif';
8080

8181
$section = new Section(0);
8282
$section->setPhpWord(new PhpWord());
@@ -98,10 +98,10 @@ public function testAddElements()
9898
$elementTypes = array('Text', 'Link', 'TextBreak', 'PageBreak',
9999
'Table', 'ListItem', 'Object', 'Image',
100100
'Title', 'TextRun', 'Footnote', 'CheckBox', 'TOC');
101-
$i = 0;
101+
$elmCount = 0;
102102
foreach ($elementTypes as $elementType) {
103-
$this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$elementType}", $elementCollection[$i]);
104-
$i++;
103+
$this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$elementType}", $elementCollection[$elmCount]);
104+
$elmCount++;
105105
}
106106
}
107107

@@ -166,6 +166,6 @@ public function testHasDifferentFirstPage()
166166
public function testAddHeaderException()
167167
{
168168
$object = new Section(1);
169-
$header = $object->addHeader('ODD');
169+
$object->addHeader('ODD');
170170
}
171171
}

tests/PhpWord/Tests/Element/TOCTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testConstructWithStyleArray()
4848
public function testConstructWithStyleName()
4949
{
5050
$object = new TOC('Font Style');
51-
$tocStyle = $object->getStyleTOC();
51+
// $tocStyle = $object->getStyleTOC();
5252

5353
$this->assertEquals('Font Style', $object->getStyleFont());
5454
}

tests/PhpWord/Tests/Element/TextRunTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function testAddLinkWithName()
114114
public function testAddTextBreak()
115115
{
116116
$oTextRun = new TextRun();
117-
$element = $oTextRun->addTextBreak(2);
117+
$oTextRun->addTextBreak(2);
118118

119119
$this->assertCount(2, $oTextRun->getElements());
120120
}

tests/PhpWord/Tests/Shared/FontTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ class FontTest extends \PHPUnit_Framework_TestCase
2525
*/
2626
public function testConversions()
2727
{
28-
$phpWord = new PhpWord();
29-
3028
$original = 1;
3129

3230
$result = Font::fontSizeToPixels($original);

tests/PhpWord/Tests/Style/CellTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public function testBorderColor()
5656
{
5757
$object = new Cell();
5858

59-
$default = '000000';
6059
$value = 'FF0000';
6160

6261
$object->setStyleValue('borderColor', $value);

tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public function testConstruct()
4848
public function testSetGetAbstractRendererProperties()
4949
{
5050
define('DOMPDF_ENABLE_AUTOLOAD', false);
51-
$file = __DIR__ . "/../../_files/temp.pdf";
5251

5352
$rendererName = Settings::PDF_RENDERER_DOMPDF;
5453
$rendererLibraryPath = realpath(PHPWORD_TESTS_BASE_DIR . '/../vendor/dompdf/dompdf');

tests/PhpWord/Tests/Writer/PDFTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@ public function testConstruct()
4747
public function testConstructException()
4848
{
4949
$writer = new PDF(new PhpWord());
50+
$writer->save();
5051
}
5152
}

tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,11 @@ public function testWriteParagraphStyle()
361361
$doc = TestHelperDOCX::getDocument($phpWord);
362362

363363
// Test the attributes
364-
$i = 0;
364+
$attributeCount = 0;
365365
foreach ($attributes as $key => $value) {
366-
$i++;
366+
$attributeCount++;
367367
$nodeName = ($key == 'align') ? 'jc' : $key;
368-
$path = "/w:document/w:body/w:p[{$i}]/w:pPr/w:{$nodeName}";
368+
$path = "/w:document/w:body/w:p[{$attributeCount}]/w:pPr/w:{$nodeName}";
369369
if ($key != 'align') {
370370
$value = $value ? 1 : 0;
371371
}
@@ -416,7 +416,6 @@ public function testWriteFontStyle()
416416
public function testWriteTableStyle()
417417
{
418418
$phpWord = new PhpWord();
419-
$tWidth = 120;
420419
$rHeight = 120;
421420
$cWidth = 120;
422421
$imageSrc = __DIR__ . "/../../../_files/images/earth.jpg";
@@ -511,7 +510,7 @@ public function testWriteGutterAndLineNumbering()
511510
$lineNumberingPath = '/w:document/w:body/w:sectPr/w:lnNumType';
512511

513512
$phpWord = new PhpWord();
514-
$section = $phpWord->addSection(array('gutter' => 240, 'lineNumbering' => array()));
513+
$phpWord->addSection(array('gutter' => 240, 'lineNumbering' => array()));
515514
$doc = TestHelperDOCX::getDocument($phpWord);
516515

517516
$this->assertEquals(240, $doc->getElement($pageMarginPath)->getAttribute('w:gutter'));

tests/PhpWord/Tests/Writer/Word2007Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function testGetWriterPartNull()
171171
public function testSetGetUseDiskCaching()
172172
{
173173
$phpWord = new PhpWord();
174-
$section = $phpWord->addSection();
174+
$phpWord->addSection();
175175
$object = new Word2007($phpWord);
176176
$object->setUseDiskCaching(true, PHPWORD_TESTS_BASE_DIR);
177177
$writer = new Word2007($phpWord);

0 commit comments

Comments
 (0)