From 53d34fd049026752a13183891250bd3d91c482c0 Mon Sep 17 00:00:00 2001 From: hazington Date: Wed, 4 Jan 2023 00:07:39 +0100 Subject: [PATCH] Address the CI coverage issue for the regex match assertion. --- .../Writer/Word2007/Part/DocumentTest.php | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/tests/PhpWordTests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWordTests/Writer/Word2007/Part/DocumentTest.php index 00582e12..be8f8cc4 100644 --- a/tests/PhpWordTests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWordTests/Writer/Word2007/Part/DocumentTest.php @@ -2,10 +2,8 @@ /** * This file is part of PHPWord - A pure PHP library for reading and writing * word processing documents. - * * PHPWord is free software distributed under the terms of the GNU Lesser * General Public License version 3 as published by the Free Software Foundation. - * * For the full copyright and license information, please read the LICENSE * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. @@ -61,11 +59,11 @@ class DocumentTest extends \PHPUnit\Framework\TestCase $doc = TestHelperDOCX::getDocument($phpWord); self::assertNotNull($doc); -// $this->assertTrue($doc->elementExists('/Properties/property[name="key1"]/vt:lpwstr')); -// $this->assertTrue($doc->elementExists('/Properties/property[name="key2"]/vt:bool')); -// $this->assertTrue($doc->elementExists('/Properties/property[name="key3"]/vt:i4')); -// $this->assertTrue($doc->elementExists('/Properties/property[name="key4"]/vt:r8')); -// $this->assertTrue($doc->elementExists('/Properties/property[name="key5"]/vt:lpwstr')); + // $this->assertTrue($doc->elementExists('/Properties/property[name="key1"]/vt:lpwstr')); + // $this->assertTrue($doc->elementExists('/Properties/property[name="key2"]/vt:bool')); + // $this->assertTrue($doc->elementExists('/Properties/property[name="key3"]/vt:i4')); + // $this->assertTrue($doc->elementExists('/Properties/property[name="key4"]/vt:r8')); + // $this->assertTrue($doc->elementExists('/Properties/property[name="key5"]/vt:lpwstr')); } /** @@ -408,7 +406,13 @@ class DocumentTest extends \PHPUnit\Framework\TestCase // behind $element = $doc->getElement('/w:document/w:body/w:p[2]/w:r/w:pict/v:shape'); $style = $element->getAttribute('style'); - self::assertMatchesRegularExpression('/z\-index:\-[0-9]*/', $style); + + // Try to address CI coverage issue for PHP 7.1 and 7.2 when using regex match assertions + if (method_exists(static::class, 'assertRegExp')) { + self::assertRegExp('/z\-index:\-[0-9]*/', $style); + } else { + self::assertMatchesRegularExpression('/z\-index:\-[0-9]*/', $style); + } // square $element = $doc->getElement('/w:document/w:body/w:p[4]/w:r/w:pict/v:shape/w10:wrap'); @@ -551,7 +555,13 @@ class DocumentTest extends \PHPUnit\Framework\TestCase $cell->addText('Test'); $doc = TestHelperDOCX::getDocument($phpWord); - self::assertEquals(Cell::DEFAULT_BORDER_COLOR, $doc->getElementAttribute('/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:tcBorders/w:top', 'w:color')); + self::assertEquals( + Cell::DEFAULT_BORDER_COLOR, + $doc->getElementAttribute( + '/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:tcBorders/w:top', + 'w:color' + ) + ); } /**