From abbf60a3be97eddfb4d4f58478b8c70a8c934984 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 15 May 2014 10:24:20 +0700 Subject: [PATCH] Increase minimum mass for php_sim and some test fixes --- .scrutinizer.yml | 2 +- src/PhpWord/Style/Table.php | 17 +++++++------- .../PhpWord/Tests/Element/ListItemRunTest.php | 23 +++++++------------ tests/PhpWord/Tests/Element/TitleTest.php | 12 ---------- 4 files changed, 18 insertions(+), 36 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index ab53c762..ded9a39f 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -18,7 +18,7 @@ tools: timeout: 900 php_sim: enabled: true - min_mass: 30 + min_mass: 40 php_pdepend: true php_analyzer: true sensiolabs_security_checker: true diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index 9d5cca87..4559e677 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -123,23 +123,24 @@ class Table extends Border public function __construct($tableStyle = null, $firstRowStyle = null) { $this->alignment = new Alignment(); - if ($tableStyle !== null && is_array($tableStyle)) { - $this->setStyleByArray($tableStyle); - } if ($firstRowStyle !== null && is_array($firstRowStyle)) { $this->firstRow = clone $this; unset($this->firstRow->firstRow); - unset($this->firstRow->cellMarginBottom); + unset($this->firstRow->borderInsideHSize); + unset($this->firstRow->borderInsideHColor); + unset($this->firstRow->borderInsideVSize); + unset($this->firstRow->borderInsideVColor); unset($this->firstRow->cellMarginTop); unset($this->firstRow->cellMarginLeft); unset($this->firstRow->cellMarginRight); - unset($this->firstRow->borderInsideVColor); - unset($this->firstRow->borderInsideVSize); - unset($this->firstRow->borderInsideHColor); - unset($this->firstRow->borderInsideHSize); + unset($this->firstRow->cellMarginBottom); $this->firstRow->setStyleByArray($firstRowStyle); } + + if ($tableStyle !== null && is_array($tableStyle)) { + $this->setStyleByArray($tableStyle); + } } /** diff --git a/tests/PhpWord/Tests/Element/ListItemRunTest.php b/tests/PhpWord/Tests/Element/ListItemRunTest.php index 5b3f72c8..c034a8f8 100644 --- a/tests/PhpWord/Tests/Element/ListItemRunTest.php +++ b/tests/PhpWord/Tests/Element/ListItemRunTest.php @@ -44,7 +44,7 @@ class ListItemRunTest extends \PHPUnit_Framework_TestCase */ public function testConstructString() { - $oListItemRun = new ListItemRun(0, null, null, 'pStyle'); + $oListItemRun = new ListItemRun(0, null, 'pStyle'); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\ListItemRun', $oListItemRun); $this->assertCount(0, $oListItemRun->getElements()); @@ -56,29 +56,22 @@ class ListItemRunTest extends \PHPUnit_Framework_TestCase */ public function testConstructArray() { - $oListItemRun = new ListItemRun(0, null, null, array('spacing' => 100)); + $oListItemRun = new ListItemRun(0, null, array('spacing' => 100)); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\ListItemRun', $oListItemRun); $this->assertCount(0, $oListItemRun->getElements()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oListItemRun->getParagraphStyle()); } - + /** * Get style */ public function testStyle() { - $oListItemRun = new ListItemRun( - 1, - null, - array('listType' => \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER) - ); - + $oListItemRun = new ListItemRun(1, array('listType' => \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER)); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\ListItem', $oListItemRun->getStyle()); - $this->assertEquals( - $oListItemRun->getStyle()->getListType(), - \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER - ); + $this->assertEquals($oListItemRun->getStyle()->getListType(), \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER); } /** * getDepth @@ -87,10 +80,10 @@ class ListItemRunTest extends \PHPUnit_Framework_TestCase { $iVal = rand(1, 1000); $oListItemRun = new ListItemRun($iVal); - + $this->assertEquals($oListItemRun->getDepth(), $iVal); } - + /** * Add text */ diff --git a/tests/PhpWord/Tests/Element/TitleTest.php b/tests/PhpWord/Tests/Element/TitleTest.php index 301d8bec..ca65c8eb 100644 --- a/tests/PhpWord/Tests/Element/TitleTest.php +++ b/tests/PhpWord/Tests/Element/TitleTest.php @@ -47,16 +47,4 @@ class TitleTest extends \PHPUnit_Framework_TestCase $this->assertEquals($oTitle->getStyle(), null); } - - /** - * Get bookmark Id - */ - public function testBookmarkID() - { - $oTitle = new Title('text'); - - $iVal = rand(1, 1000); - $oTitle->setBookmarkId($iVal); - $this->assertEquals($oTitle->getRelationId(), $iVal); - } }