Fix test error

This commit is contained in:
Ivan Lanin 2014-05-24 23:07:34 +07:00
parent 1e9a498ca2
commit dc6c487cd0
7 changed files with 13 additions and 9 deletions

View File

@ -312,9 +312,13 @@ class Image extends AbstractElement
} else {
$actualSource = $source;
}
if ($actualSource === null) {
return null;
}
// Can't find any case where $actualSource = null hasn't captured by
// preceding exceptions. Please uncomment when you find the case and
// put the case into Element\ImageTest.
// if ($actualSource === null) {
// return null;
// }
// Read image binary data and convert to hex/base64 string
if ($this->sourceType == self::SOURCE_GD) {

View File

@ -344,7 +344,7 @@ class Settings
// Parse config file
$config = array();
if ($configFile !== null) {
$config = parse_ini_file($configFile);
$config = @parse_ini_file($configFile);
if ($config === false) {
return $config;
}

View File

@ -214,7 +214,7 @@ class Html
*/
case 'li':
$cNodes = $node->childNodes;
if ($cNodes->length > 0) {
if (count($cNodes) > 0) {
$text = '';
foreach ($cNodes as $cNode) {
if ($cNode->nodeName == '#text') {
@ -240,7 +240,7 @@ class Html
*/
if ($node->nodeName != 'li') {
$cNodes = $node->childNodes;
if ($cNodes->length > 0) {
if (count($cNodes) > 0) {
foreach ($cNodes as $cNode) {
self::parseNode($cNode, $newobject, $styles, $data);
}

View File

@ -145,7 +145,6 @@ class Numbering extends AbstractPart
$xmlWriter->startElement('w:tab');
$xmlWriter->writeAttribute('w:val', 'num');
$xmlWriter->writeAttributeIf($tabPos !== null, 'w:pos', $tabPos);
$xmlWriter->writeAttribute('w:pos', $tabPos);
$xmlWriter->endElement(); // w:tab
$xmlWriter->endElement(); // w:tabs

View File

@ -38,6 +38,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($oImage->getSource(), $src);
$this->assertEquals($oImage->getMediaId(), md5($src));
$this->assertEquals($oImage->isWatermark(), false);
$this->assertEquals($oImage->getSourceType(), Image::SOURCE_LOCAL);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle());
}

View File

@ -73,7 +73,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
{
$expected = 'landscape';
$object = new Section(0);
$object->setSettings(array('orientation' => $expected));
$object->setSettings(array('orientation' => $expected, 'foo' => null));
$this->assertEquals($expected, $object->getSettings()->getOrientation());
}

View File

@ -111,6 +111,6 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expected, Settings::loadConfig(__DIR__ . '/../../../phpword.ini.dist'));
// Test with invalid file
$this->assertEmpty(Settings::loadConfig(__DIR__ . '/files/xsl/passthrough.xsl'));
$this->assertEmpty(Settings::loadConfig(__DIR__ . '/../../../phpunit.xml.dist'));
}
}