QA: PHPMD fixes for `tests`; Some adjustment for Travis build

This commit is contained in:
Ivan Lanin 2014-05-04 22:53:56 +07:00
parent 3d19256c9c
commit d1022a9e3c
16 changed files with 27 additions and 27 deletions

View File

@ -52,13 +52,13 @@ script:
## PHP Copy/Paste Detector ## PHP Copy/Paste Detector
- phpcpd src/ tests/ --verbose - phpcpd src/ tests/ --verbose
## PHP Mess Detector ## PHP Mess Detector
- phpmd src/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php - phpmd src/,tests/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php
## PHPLOC ## PHPLOC
#- php phploc.phar src/ #- php phploc.phar src/
## PHPUnit ## PHPUnit
- phpunit -c ./ --coverage-text --coverage-html ./build/coverage - phpunit -c ./ --coverage-text --coverage-html ./build/coverage
## PHPDocumentor ## PHPDocumentor
- vendor/bin/phpdoc.php -d ./src -t ./build/docs - vendor/bin/phpdoc.php -d ./src -t ./build/docs -i ./src/PhpWord/Shared/PCLZip/
after_script: after_script:
## PHPDocumentor ## PHPDocumentor

View File

@ -31,7 +31,7 @@ if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" ==
echo "--DEBUG : Git" echo "--DEBUG : Git"
git add -f . git add -f .
git commit -m "PHPDocumentor (Travis Build : $TRAVIS_BUILD_NUMBER - Branch : $TRAVIS_BRANCH)" git commit -m "PHPDocumentor (Travis Build: $TRAVIS_BUILD_NUMBER - Branch: $TRAVIS_BRANCH)"
git push -fq origin gh-pages > /dev/null git push -fq origin gh-pages > /dev/null
echo -e "Published PHPDoc to gh-pages.\n" echo -e "Published PHPDoc to gh-pages.\n"

View File

@ -4,7 +4,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers
## 0.11.0 - Not yet released ## 0.11.0 - Not yet released
PHPWord license is changed from LGPL 2.1 to LGPL 3 in this release. This release changed PHPWord license from LGPL 2.1 to LGPL 3.
### Features ### Features

View File

@ -21,4 +21,7 @@
</exclude> </exclude>
</whitelist> </whitelist>
</filter> </filter>
<logging>
<log type="coverage-html" target="./build/coverage" charset="UTF-8" highlight="true" />
</logging>
</phpunit> </phpunit>

View File

@ -219,7 +219,7 @@ class CellTest extends \PHPUnit_Framework_TestCase
{ {
$src = __DIR__ . "/../_files/xsl/passthrough.xsl"; $src = __DIR__ . "/../_files/xsl/passthrough.xsl";
$oCell = new Cell('section', 1); $oCell = new Cell('section', 1);
$element = $oCell->addObject($src); $oCell->addObject($src);
} }
/** /**
@ -255,7 +255,7 @@ class CellTest extends \PHPUnit_Framework_TestCase
public function testAddPreserveTextException() public function testAddPreserveTextException()
{ {
$oCell = new Cell('section', 1); $oCell = new Cell('section', 1);
$element = $oCell->addPreserveText('text'); $oCell->addPreserveText('text');
} }
/** /**

View File

@ -107,6 +107,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
public function testInvalidImagePhp() public function testInvalidImagePhp()
{ {
$object = new Image('test.php'); $object = new Image('test.php');
$object->getSource();
} }
/** /**
@ -117,6 +118,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
public function testUnsupportedImage() public function testUnsupportedImage()
{ {
$object = new Image('http://samples.libav.org/image-samples/RACECAR.BMP'); $object = new Image('http://samples.libav.org/image-samples/RACECAR.BMP');
$object->getSource();
} }
/** /**

View File

@ -34,15 +34,14 @@ class ObjectTest extends \PHPUnit_Framework_TestCase
/** /**
* Create new instance with non-supported files * Create new instance with non-supported files
*
* @expectedException \PhpOffice\PhpWord\Exception\InvalidObjectException
*/ */
public function testConstructWithNotSupportedFiles() public function testConstructWithNotSupportedFiles()
{ {
$src = __DIR__ . "/../_files/xsl/passthrough.xsl"; $src = __DIR__ . "/../_files/xsl/passthrough.xsl";
$oObject = new Object($src); $oObject = new Object($src);
$oObject->getSource();
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Object', $oObject);
$this->assertEquals($oObject->getSource(), null);
$this->assertEquals($oObject->getStyle(), null);
} }
/** /**

View File

@ -76,7 +76,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
{ {
$objectSource = __DIR__ . "/../_files/documents/reader.docx"; $objectSource = __DIR__ . "/../_files/documents/reader.docx";
$imageSource = __DIR__ . "/../_files/images/PhpWord.png"; $imageSource = __DIR__ . "/../_files/images/PhpWord.png";
$imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif'; // $imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif';
$section = new Section(0); $section = new Section(0);
$section->setPhpWord(new PhpWord()); $section->setPhpWord(new PhpWord());
@ -98,10 +98,10 @@ class SectionTest extends \PHPUnit_Framework_TestCase
$elementTypes = array('Text', 'Link', 'TextBreak', 'PageBreak', $elementTypes = array('Text', 'Link', 'TextBreak', 'PageBreak',
'Table', 'ListItem', 'Object', 'Image', 'Table', 'ListItem', 'Object', 'Image',
'Title', 'TextRun', 'Footnote', 'CheckBox', 'TOC'); 'Title', 'TextRun', 'Footnote', 'CheckBox', 'TOC');
$i = 0; $elmCount = 0;
foreach ($elementTypes as $elementType) { foreach ($elementTypes as $elementType) {
$this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$elementType}", $elementCollection[$i]); $this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$elementType}", $elementCollection[$elmCount]);
$i++; $elmCount++;
} }
} }
@ -166,6 +166,6 @@ class SectionTest extends \PHPUnit_Framework_TestCase
public function testAddHeaderException() public function testAddHeaderException()
{ {
$object = new Section(1); $object = new Section(1);
$header = $object->addHeader('ODD'); $object->addHeader('ODD');
} }
} }

View File

@ -48,7 +48,7 @@ class TOCTest extends \PHPUnit_Framework_TestCase
public function testConstructWithStyleName() public function testConstructWithStyleName()
{ {
$object = new TOC('Font Style'); $object = new TOC('Font Style');
$tocStyle = $object->getStyleTOC(); // $tocStyle = $object->getStyleTOC();
$this->assertEquals('Font Style', $object->getStyleFont()); $this->assertEquals('Font Style', $object->getStyleFont());
} }

View File

@ -114,7 +114,7 @@ class TextRunTest extends \PHPUnit_Framework_TestCase
public function testAddTextBreak() public function testAddTextBreak()
{ {
$oTextRun = new TextRun(); $oTextRun = new TextRun();
$element = $oTextRun->addTextBreak(2); $oTextRun->addTextBreak(2);
$this->assertCount(2, $oTextRun->getElements()); $this->assertCount(2, $oTextRun->getElements());
} }

View File

@ -25,8 +25,6 @@ class FontTest extends \PHPUnit_Framework_TestCase
*/ */
public function testConversions() public function testConversions()
{ {
$phpWord = new PhpWord();
$original = 1; $original = 1;
$result = Font::fontSizeToPixels($original); $result = Font::fontSizeToPixels($original);

View File

@ -56,7 +56,6 @@ class CellTest extends \PHPUnit_Framework_TestCase
{ {
$object = new Cell(); $object = new Cell();
$default = '000000';
$value = 'FF0000'; $value = 'FF0000';
$object->setStyleValue('borderColor', $value); $object->setStyleValue('borderColor', $value);

View File

@ -48,7 +48,6 @@ class DomPDFTest extends \PHPUnit_Framework_TestCase
public function testSetGetAbstractRendererProperties() public function testSetGetAbstractRendererProperties()
{ {
define('DOMPDF_ENABLE_AUTOLOAD', false); define('DOMPDF_ENABLE_AUTOLOAD', false);
$file = __DIR__ . "/../../_files/temp.pdf";
$rendererName = Settings::PDF_RENDERER_DOMPDF; $rendererName = Settings::PDF_RENDERER_DOMPDF;
$rendererLibraryPath = realpath(PHPWORD_TESTS_BASE_DIR . '/../vendor/dompdf/dompdf'); $rendererLibraryPath = realpath(PHPWORD_TESTS_BASE_DIR . '/../vendor/dompdf/dompdf');

View File

@ -47,5 +47,6 @@ class PDFTest extends \PHPUnit_Framework_TestCase
public function testConstructException() public function testConstructException()
{ {
$writer = new PDF(new PhpWord()); $writer = new PDF(new PhpWord());
$writer->save();
} }
} }

View File

@ -361,11 +361,11 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);
// Test the attributes // Test the attributes
$i = 0; $attributeCount = 0;
foreach ($attributes as $key => $value) { foreach ($attributes as $key => $value) {
$i++; $attributeCount++;
$nodeName = ($key == 'align') ? 'jc' : $key; $nodeName = ($key == 'align') ? 'jc' : $key;
$path = "/w:document/w:body/w:p[{$i}]/w:pPr/w:{$nodeName}"; $path = "/w:document/w:body/w:p[{$attributeCount}]/w:pPr/w:{$nodeName}";
if ($key != 'align') { if ($key != 'align') {
$value = $value ? 1 : 0; $value = $value ? 1 : 0;
} }
@ -416,7 +416,6 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
public function testWriteTableStyle() public function testWriteTableStyle()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$tWidth = 120;
$rHeight = 120; $rHeight = 120;
$cWidth = 120; $cWidth = 120;
$imageSrc = __DIR__ . "/../../../_files/images/earth.jpg"; $imageSrc = __DIR__ . "/../../../_files/images/earth.jpg";
@ -511,7 +510,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$lineNumberingPath = '/w:document/w:body/w:sectPr/w:lnNumType'; $lineNumberingPath = '/w:document/w:body/w:sectPr/w:lnNumType';
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->addSection(array('gutter' => 240, 'lineNumbering' => array())); $phpWord->addSection(array('gutter' => 240, 'lineNumbering' => array()));
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);
$this->assertEquals(240, $doc->getElement($pageMarginPath)->getAttribute('w:gutter')); $this->assertEquals(240, $doc->getElement($pageMarginPath)->getAttribute('w:gutter'));

View File

@ -171,7 +171,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
public function testSetGetUseDiskCaching() public function testSetGetUseDiskCaching()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->addSection(); $phpWord->addSection();
$object = new Word2007($phpWord); $object = new Word2007($phpWord);
$object->setUseDiskCaching(true, PHPWORD_TESTS_BASE_DIR); $object->setUseDiskCaching(true, PHPWORD_TESTS_BASE_DIR);
$writer = new Word2007($phpWord); $writer = new Word2007($phpWord);