Skip to content

Commit 2ecc569

Browse files
authored
Merge pull request #4 from KaririCode-Framework/develop
fix(ci): eliminate PHPUnit 12 false-positive coverage warnings
2 parents f81d320 + 8536688 commit 2ecc569

2 files changed

Lines changed: 18 additions & 38 deletions

File tree

.github/workflows/code-quality.yml

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,16 @@ jobs:
9494
- name: Initialize devkit
9595
run: kcode init
9696

97-
# Patch generated phpunit.xml.dist — PHPUnit 12 emits false-positive warnings
98-
# for classes extending built-ins outside <source>; use python3 for reliable XML edit.
97+
# Patch generated phpunit.xml.dist — disable failOnWarning and strict
98+
# coverage metadata to avoid false-positive warnings from PHPUnit 12.
9999
- name: Patch phpunit.xml.dist
100100
run: |
101-
python3 - <<'EOF'
102-
import xml.etree.ElementTree as ET
103-
ET.register_namespace('', 'http://www.w3.org/2001/XMLSchema-instance')
104-
path = '.kcode/phpunit.xml.dist'
105-
tree = ET.parse(path)
106-
root = tree.getroot()
107-
root.set('failOnWarning', 'false')
108-
root.set('failOnRisky', 'false')
109-
root.set('beStrictAboutCoverageMetadata', 'false')
110-
src = root.find('source')
111-
if src is not None:
112-
src.attrib.pop('restrictWarnings', None)
113-
src.attrib.pop('restrictDeprecations', None)
114-
src.attrib.pop('restrictNotices', None)
115-
tree.write(path, xml_declaration=True, encoding='UTF-8')
116-
EOF
101+
sed -i 's/failOnWarning="true"/failOnWarning="false"/' .kcode/phpunit.xml.dist
102+
sed -i 's/failOnRisky="true"/failOnRisky="false"/' .kcode/phpunit.xml.dist
103+
sed -i 's/beStrictAboutCoverageMetadata="true"/beStrictAboutCoverageMetadata="false"/' .kcode/phpunit.xml.dist
104+
sed -i 's/ restrictWarnings="true"//g' .kcode/phpunit.xml.dist
105+
sed -i 's/ restrictDeprecations="true"//g' .kcode/phpunit.xml.dist
106+
sed -i 's/ restrictNotices="true"//g' .kcode/phpunit.xml.dist
117107
118108
# Runs PHPStan Level 9 then Psalm sequentially — both must pass
119109
- name: Run PHPStan + Psalm via kcode
@@ -181,26 +171,16 @@ jobs:
181171
- name: Initialize devkit
182172
run: kcode init
183173

184-
# Patch generated phpunit.xml.dist — PHPUnit 12 emits false-positive warnings
185-
# for classes extending built-ins outside <source>; use python3 for reliable XML edit.
174+
# Patch generated phpunit.xml.dist — disable failOnWarning and strict
175+
# coverage metadata to avoid false-positive warnings from PHPUnit 12.
186176
- name: Patch phpunit.xml.dist
187177
run: |
188-
python3 - <<'EOF'
189-
import xml.etree.ElementTree as ET
190-
ET.register_namespace('', 'http://www.w3.org/2001/XMLSchema-instance')
191-
path = '.kcode/phpunit.xml.dist'
192-
tree = ET.parse(path)
193-
root = tree.getroot()
194-
root.set('failOnWarning', 'false')
195-
root.set('failOnRisky', 'false')
196-
root.set('beStrictAboutCoverageMetadata', 'false')
197-
src = root.find('source')
198-
if src is not None:
199-
src.attrib.pop('restrictWarnings', None)
200-
src.attrib.pop('restrictDeprecations', None)
201-
src.attrib.pop('restrictNotices', None)
202-
tree.write(path, xml_declaration=True, encoding='UTF-8')
203-
EOF
178+
sed -i 's/failOnWarning="true"/failOnWarning="false"/' .kcode/phpunit.xml.dist
179+
sed -i 's/failOnRisky="true"/failOnRisky="false"/' .kcode/phpunit.xml.dist
180+
sed -i 's/beStrictAboutCoverageMetadata="true"/beStrictAboutCoverageMetadata="false"/' .kcode/phpunit.xml.dist
181+
sed -i 's/ restrictWarnings="true"//g' .kcode/phpunit.xml.dist
182+
sed -i 's/ restrictDeprecations="true"//g' .kcode/phpunit.xml.dist
183+
sed -i 's/ restrictNotices="true"//g' .kcode/phpunit.xml.dist
204184
205185
- name: Run tests with coverage (pcov)
206186
run: kcode test --coverage

tests/Unit/Exception/DiscoveryExceptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
namespace KaririCode\ClassDiscovery\Tests\Unit\Exception;
66

77
use KaririCode\ClassDiscovery\Exception\DiscoveryException;
8-
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\Attributes\UsesClass;
99
use PHPUnit\Framework\TestCase;
1010

11-
#[CoversClass(DiscoveryException::class)]
11+
#[UsesClass(DiscoveryException::class)]
1212
final class DiscoveryExceptionTest extends TestCase
1313
{
1414
#[\PHPUnit\Framework\Attributes\DataProvider('namedConstructorProvider')]

0 commit comments

Comments
 (0)