Add unit tests & add array type checks
This commit is contained in:
parent
ca25eba8aa
commit
274f50ce5a
|
|
@ -41,6 +41,9 @@ This is the last version to support PHP 5.3
|
|||
- Fix incorrect image size between windows and mac - @bskrtich #874
|
||||
- Fix adding HTML table to document - @mogilvie @arivanbastos #324
|
||||
|
||||
###Deprecated
|
||||
- PhpWord->getProtection(), get it from the settings instead PhpWord->getSettings()->getDocumentProtection();
|
||||
|
||||
v0.13.0 (31 July 2016)
|
||||
-------------------
|
||||
This release brings several improvements in `TemplateProcessor`, automatic output escaping feature for OOXML, ODF, HTML, and RTF (turned off, by default).
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ class Html
|
|||
{
|
||||
if ('li' != $node->nodeName) {
|
||||
$cNodes = $node->childNodes;
|
||||
if (count($cNodes) > 0) {
|
||||
if (!empty($cNodes)) {
|
||||
foreach ($cNodes as $cNode) {
|
||||
if ($element instanceof AbstractContainer || $element instanceof Table || $element instanceof Row) {
|
||||
self::parseNode($cNode, $element, $styles, $data);
|
||||
|
|
@ -389,7 +389,7 @@ class Html
|
|||
private static function parseListItem($node, $element, &$styles, $data)
|
||||
{
|
||||
$cNodes = $node->childNodes;
|
||||
if (count($cNodes) > 0) {
|
||||
if (!empty($cNodes)) {
|
||||
$text = '';
|
||||
foreach ($cNodes as $cNode) {
|
||||
if ($cNode->nodeName == '#text') {
|
||||
|
|
|
|||
|
|
@ -140,7 +140,8 @@ class ZipArchive
|
|||
} else {
|
||||
$zip = new \PclZip($this->filename);
|
||||
$this->tempDir = Settings::getTempDir();
|
||||
$this->numFiles = count($zip->listContent());
|
||||
$zipContent = $zip->listContent();
|
||||
$this->numFiles = is_array($zipContent) ? count($zipContent) : 0;
|
||||
}
|
||||
$this->zip = $zip;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class Border extends AbstractStyle
|
|||
$content = '';
|
||||
|
||||
$sides = array('top', 'left', 'right', 'bottom');
|
||||
$sizeCount = count($this->sizes) - 1;
|
||||
$sizeCount = count($this->sizes);
|
||||
|
||||
// Page border measure
|
||||
// 8 = from text, infront off; 32 = from edge, infront on; 40 = from edge, infront off
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class Settings extends AbstractPart
|
|||
{
|
||||
if ($settingValue == '') {
|
||||
$xmlWriter->writeElement($settingKey);
|
||||
} else {
|
||||
} elseif (is_array($settingValue) && !empty($settingValue)) {
|
||||
$xmlWriter->startElement($settingKey);
|
||||
|
||||
/** @var array $settingValue Type hint */
|
||||
|
|
@ -154,7 +154,7 @@ class Settings extends AbstractPart
|
|||
$this->setDocumentProtection($documentSettings->getDocumentProtection());
|
||||
$this->setProofState($documentSettings->getProofState());
|
||||
$this->setZoom($documentSettings->getZoom());
|
||||
$this->getCompatibility();
|
||||
$this->setCompatibility();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -216,6 +216,7 @@ class Settings extends AbstractPart
|
|||
private function setRevisionView(TrackChangesView $trackChangesView = null)
|
||||
{
|
||||
if ($trackChangesView != null) {
|
||||
$revisionView = array();
|
||||
$revisionView['w:markup'] = $trackChangesView->hasMarkup() ? 'true' : 'false';
|
||||
$revisionView['w:comments'] = $trackChangesView->hasComments() ? 'true' : 'false';
|
||||
$revisionView['w:insDel'] = $trackChangesView->hasInsDel() ? 'true' : 'false';
|
||||
|
|
@ -259,7 +260,7 @@ class Settings extends AbstractPart
|
|||
/**
|
||||
* Get compatibility setting.
|
||||
*/
|
||||
private function getCompatibility()
|
||||
private function setCompatibility()
|
||||
{
|
||||
$compatibility = $this->getParentWriter()->getPhpWord()->getCompatibility();
|
||||
if ($compatibility->getOoxmlVersion() !== null) {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Writer\RTF;
|
||||
|
||||
use PhpOffice\PhpWord\Writer\RTF\Style\Border;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\RTF\Style subnamespace
|
||||
*/
|
||||
|
|
@ -35,4 +37,22 @@ class StyleTest extends \PHPUnit\Framework\TestCase
|
|||
$this->assertEquals('', $object->write());
|
||||
}
|
||||
}
|
||||
|
||||
public function testBorderWithNonRegisteredColors()
|
||||
{
|
||||
$border = new Border();
|
||||
$border->setSizes(array(1, 2, 3, 4));
|
||||
$border->setColors(array('#FF0000', '#FF0000', '#FF0000', '#FF0000'));
|
||||
$border->setSizes(array(20, 20, 20, 20));
|
||||
|
||||
$content = $border->write();
|
||||
|
||||
$expected = '\pgbrdropt32';
|
||||
$expected .= '\pgbrdrt\brdrs\brdrw20\brdrcf0\brsp480 ';
|
||||
$expected .= '\pgbrdrl\brdrs\brdrw20\brdrcf0\brsp480 ';
|
||||
$expected .= '\pgbrdrr\brdrs\brdrw20\brdrcf0\brsp480 ';
|
||||
$expected .= '\pgbrdrb\brdrs\brdrw20\brdrcf0\brsp480 ';
|
||||
|
||||
$this->assertEquals($expected, $content);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue