Skip to content

Commit 26ceab6

Browse files
Closes #1091
1 parent 96dc046 commit 26ceab6

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

ChangeLog-12.3.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
44

5+
## [12.3.6] - 2025-MM-DD
6+
7+
### Fixed
8+
9+
* [#1091](https://github.com/sebastianbergmann/php-code-coverage/issues/1091): HTML report renderer uses code coverage driver
10+
511
## [12.3.5] - 2025-09-01
612

713
### Changed
@@ -44,6 +50,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
4450

4551
* [#1080](https://github.com/sebastianbergmann/php-code-coverage/pull/1080): Support for reporting code coverage information in OpenClover XML format; unlike the existing Clover XML reporter, which remains unchanged, the XML documents generated by this new reporter validate against the OpenClover project's XML schema definition, with one exception: we do not generate the `<testproject>` element. This feature is experimental and the generated XML might change in order to improve compliance with the OpenClover project's XML schema definition further. Such changes will be made in bugfix and/or minor releases even if they break backward compatibility.
4652

53+
[12.3.6]: https://github.com/sebastianbergmann/php-code-coverage/compare/12.3.5...main
4754
[12.3.5]: https://github.com/sebastianbergmann/php-code-coverage/compare/12.3.4...12.3.5
4855
[12.3.4]: https://github.com/sebastianbergmann/php-code-coverage/compare/12.3.3...12.3.4
4956
[12.3.3]: https://github.com/sebastianbergmann/php-code-coverage/compare/12.3.2...12.3.3

src/CodeCoverage.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ final class CodeCoverage
6868
private ?FileAnalyser $analyser = null;
6969
private ?string $cacheDirectory = null;
7070
private ?Directory $cachedReport = null;
71+
private bool $collectBranchAndPathCoverage = false;
7172

7273
public function __construct(Driver $driver, Filter $filter)
7374
{
@@ -384,16 +385,20 @@ public function excludeSubclassesOfThisClassFromUnintentionallyCoveredCodeCheck(
384385
public function enableBranchAndPathCoverage(): void
385386
{
386387
$this->driver->enableBranchAndPathCoverage();
388+
389+
$this->collectBranchAndPathCoverage = true;
387390
}
388391

389392
public function disableBranchAndPathCoverage(): void
390393
{
391394
$this->driver->disableBranchAndPathCoverage();
395+
396+
$this->collectBranchAndPathCoverage = false;
392397
}
393398

394399
public function collectsBranchAndPathCoverage(): bool
395400
{
396-
return $this->driver->collectsBranchAndPathCoverage();
401+
return $this->collectBranchAndPathCoverage;
397402
}
398403

399404
public function validate(TargetCollection $targets): ValidationResult

tests/src/TestCase.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,8 +1083,6 @@ protected function getPathCoverageForBankAccount(): CodeCoverage
10831083

10841084
$stub = $this->createStub(Driver::class);
10851085

1086-
$stub->method('collectsBranchAndPathCoverage')->willReturn(true);
1087-
10881086
$stub->method('stop')
10891087
->willReturn(...$data);
10901088

@@ -1093,6 +1091,8 @@ protected function getPathCoverageForBankAccount(): CodeCoverage
10931091

10941092
$coverage = new CodeCoverage($stub, $filter);
10951093

1094+
$coverage->enableBranchAndPathCoverage();
1095+
10961096
$coverage->start(
10971097
'BankAccountTest::testBalanceIsInitiallyZero',
10981098
null,
@@ -1162,8 +1162,6 @@ protected function getPathCoverageForSourceWithoutNamespace(): CodeCoverage
11621162

11631163
$stub = $this->createStub(Driver::class);
11641164

1165-
$stub->method('collectsBranchAndPathCoverage')->willReturn(true);
1166-
11671165
$stub->method('stop')
11681166
->willReturn(...$data);
11691167

@@ -1172,6 +1170,8 @@ protected function getPathCoverageForSourceWithoutNamespace(): CodeCoverage
11721170

11731171
$coverage = new CodeCoverage($stub, $filter);
11741172

1173+
$coverage->enableBranchAndPathCoverage();
1174+
11751175
$coverage->start(
11761176
'faketest',
11771177
null,
@@ -1472,6 +1472,8 @@ protected function getPathCoverageForBankAccountForFirstTwoTests(): CodeCoverage
14721472

14731473
$coverage = new CodeCoverage($stub, $filter);
14741474

1475+
$coverage->enableBranchAndPathCoverage();
1476+
14751477
$coverage->start(
14761478
'BankAccountTest::testBalanceIsInitiallyZero',
14771479
null,
@@ -1519,6 +1521,8 @@ protected function getPathCoverageForBankAccountForLastTwoTests(): CodeCoverage
15191521

15201522
$coverage = new CodeCoverage($stub, $filter);
15211523

1524+
$coverage->enableBranchAndPathCoverage();
1525+
15221526
$coverage->start(
15231527
'BankAccountTest::testBalanceCannotBecomeNegative2',
15241528
);

0 commit comments

Comments
 (0)