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
- phpcpd src/ tests/ --verbose
## 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
#- php phploc.phar src/
## PHPUnit
- phpunit -c ./ --coverage-text --coverage-html ./build/coverage
## 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:
## PHPDocumentor

View File

@ -31,7 +31,7 @@ if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" ==
echo "--DEBUG : Git"
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
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
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

View File

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

View File

@ -219,7 +219,7 @@ class CellTest extends \PHPUnit_Framework_TestCase
{
$src = __DIR__ . "/../_files/xsl/passthrough.xsl";
$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()
{
$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()
{
$object = new Image('test.php');
$object->getSource();
}
/**
@ -117,6 +118,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
public function testUnsupportedImage()
{
$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
*
* @expectedException \PhpOffice\PhpWord\Exception\InvalidObjectException
*/
public function testConstructWithNotSupportedFiles()
{
$src = __DIR__ . "/../_files/xsl/passthrough.xsl";
$oObject = new Object($src);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Object', $oObject);
$this->assertEquals($oObject->getSource(), null);
$this->assertEquals($oObject->getStyle(), null);
$oObject->getSource();
}
/**

View File

@ -76,7 +76,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
{
$objectSource = __DIR__ . "/../_files/documents/reader.docx";
$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->setPhpWord(new PhpWord());
@ -98,10 +98,10 @@ class SectionTest extends \PHPUnit_Framework_TestCase
$elementTypes = array('Text', 'Link', 'TextBreak', 'PageBreak',
'Table', 'ListItem', 'Object', 'Image',
'Title', 'TextRun', 'Footnote', 'CheckBox', 'TOC');
$i = 0;
$elmCount = 0;
foreach ($elementTypes as $elementType) {
$this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$elementType}", $elementCollection[$i]);
$i++;
$this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$elementType}", $elementCollection[$elmCount]);
$elmCount++;
}
}
@ -166,6 +166,6 @@ class SectionTest extends \PHPUnit_Framework_TestCase
public function testAddHeaderException()
{
$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()
{
$object = new TOC('Font Style');
$tocStyle = $object->getStyleTOC();
// $tocStyle = $object->getStyleTOC();
$this->assertEquals('Font Style', $object->getStyleFont());
}

View File

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

View File

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

View File

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

View File

@ -48,7 +48,6 @@ class DomPDFTest extends \PHPUnit_Framework_TestCase
public function testSetGetAbstractRendererProperties()
{
define('DOMPDF_ENABLE_AUTOLOAD', false);
$file = __DIR__ . "/../../_files/temp.pdf";
$rendererName = Settings::PDF_RENDERER_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()
{
$writer = new PDF(new PhpWord());
$writer->save();
}
}

View File

@ -361,11 +361,11 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$doc = TestHelperDOCX::getDocument($phpWord);
// Test the attributes
$i = 0;
$attributeCount = 0;
foreach ($attributes as $key => $value) {
$i++;
$attributeCount++;
$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') {
$value = $value ? 1 : 0;
}
@ -416,7 +416,6 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
public function testWriteTableStyle()
{
$phpWord = new PhpWord();
$tWidth = 120;
$rHeight = 120;
$cWidth = 120;
$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';
$phpWord = new PhpWord();
$section = $phpWord->addSection(array('gutter' => 240, 'lineNumbering' => array()));
$phpWord->addSection(array('gutter' => 240, 'lineNumbering' => array()));
$doc = TestHelperDOCX::getDocument($phpWord);
$this->assertEquals(240, $doc->getElement($pageMarginPath)->getAttribute('w:gutter'));

View File

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