Skip to content

Achieve 100% line/method coverage; fix fabricated CHANGELOG entry#33

Merged
voku merged 2 commits into
masterfrom
copilot/update-changelog-increase-coverage
Apr 24, 2026
Merged

Achieve 100% line/method coverage; fix fabricated CHANGELOG entry#33
voku merged 2 commits into
masterfrom
copilot/update-changelog-increase-coverage

Conversation

Copilot AI commented Apr 24, 2026

Copy link
Copy Markdown

The previous session added a CHANGELOG entry claiming a coverage improvement it didn't actually make — MiscCoverageTest.php had already been merged via a prior PR. This branch reverts that entry and does the real work: covering the three genuinely uncovered branches.

New tests (MiscCoverageTest.php)

Test Target Trigger
testNestedBlockquoteWithWidthReducesWidth convertNested line 630 — width -= 2 blockquote with width > 0 option
testPregCallbackUnknownElementReturnsEmpty pregCallback line 815 — return '' fallback reflection call with unknown element name
testConvertElementWithNoOptionsReturnsInputUnchanged convertElement line 939 — return $str fallback element options overridden to false

The return '' branch in pregCallback and return $str in convertElement are unreachable via normal HTML input, so the former uses reflection and the latter uses an option override:

// line 815 — via reflection
$ref = new \ReflectionMethod($html2text, 'pregCallback');
$ref->setAccessible(true);
$result = $ref->invoke($html2text, ['element' => 'unknownelement', 'value' => 'test']);

// line 939 — options override forces null options for h1
$html2text = new Html2Text('<h1>Hello</h1>', ['elements' => ['h1' => false]]);

Coverage delta

Metric Before After
Lines 98.72% (232/235) 100% (235/235)
Methods 82.35% (14/17) 100% (17/17)
Classes 0% 100%

CHANGELOG

Reverted the inaccurate 5.0.5 entry; replaced with an entry that accurately describes only this branch's work.


This change is Reviewable

Copilot AI and others added 2 commits April 24, 2026 00:30
@voku voku marked this pull request as ready for review April 24, 2026 01:07
@voku voku merged commit 6031d21 into master Apr 24, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants