Skip to content

Commit 53d34fd

Browse files
author
hazington
committed
Address the CI coverage issue for the regex match assertion.
1 parent 679a738 commit 53d34fd

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

tests/PhpWordTests/Writer/Word2007/Part/DocumentTest.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
/**
33
* This file is part of PHPWord - A pure PHP library for reading and writing
44
* word processing documents.
5-
*
65
* PHPWord is free software distributed under the terms of the GNU Lesser
76
* General Public License version 3 as published by the Free Software Foundation.
8-
*
97
* For the full copyright and license information, please read the LICENSE
108
* file that was distributed with this source code. For the full list of
119
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
@@ -61,11 +59,11 @@ public function testWriteCustomProps(): void
6159
$doc = TestHelperDOCX::getDocument($phpWord);
6260
self::assertNotNull($doc);
6361

64-
// $this->assertTrue($doc->elementExists('/Properties/property[name="key1"]/vt:lpwstr'));
65-
// $this->assertTrue($doc->elementExists('/Properties/property[name="key2"]/vt:bool'));
66-
// $this->assertTrue($doc->elementExists('/Properties/property[name="key3"]/vt:i4'));
67-
// $this->assertTrue($doc->elementExists('/Properties/property[name="key4"]/vt:r8'));
68-
// $this->assertTrue($doc->elementExists('/Properties/property[name="key5"]/vt:lpwstr'));
62+
// $this->assertTrue($doc->elementExists('/Properties/property[name="key1"]/vt:lpwstr'));
63+
// $this->assertTrue($doc->elementExists('/Properties/property[name="key2"]/vt:bool'));
64+
// $this->assertTrue($doc->elementExists('/Properties/property[name="key3"]/vt:i4'));
65+
// $this->assertTrue($doc->elementExists('/Properties/property[name="key4"]/vt:r8'));
66+
// $this->assertTrue($doc->elementExists('/Properties/property[name="key5"]/vt:lpwstr'));
6967
}
7068

7169
/**
@@ -408,7 +406,13 @@ public function testWriteImage(): void
408406
// behind
409407
$element = $doc->getElement('/w:document/w:body/w:p[2]/w:r/w:pict/v:shape');
410408
$style = $element->getAttribute('style');
411-
self::assertMatchesRegularExpression('/z\-index:\-[0-9]*/', $style);
409+
410+
// Try to address CI coverage issue for PHP 7.1 and 7.2 when using regex match assertions
411+
if (method_exists(static::class, 'assertRegExp')) {
412+
self::assertRegExp('/z\-index:\-[0-9]*/', $style);
413+
} else {
414+
self::assertMatchesRegularExpression('/z\-index:\-[0-9]*/', $style);
415+
}
412416

413417
// square
414418
$element = $doc->getElement('/w:document/w:body/w:p[4]/w:r/w:pict/v:shape/w10:wrap');
@@ -551,7 +555,13 @@ public function testWriteDefaultColor(): void
551555
$cell->addText('Test');
552556

553557
$doc = TestHelperDOCX::getDocument($phpWord);
554-
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'));
558+
self::assertEquals(
559+
Cell::DEFAULT_BORDER_COLOR,
560+
$doc->getElementAttribute(
561+
'/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:tcBorders/w:top',
562+
'w:color'
563+
)
564+
);
555565
}
556566

557567
/**

0 commit comments

Comments
 (0)