From 5b5898f829955ff7fe121b3d0fc55bb54cfbcfcb Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Wed, 9 Feb 2022 08:49:16 +0100 Subject: [PATCH 01/10] Exclude non-executable lines --- src/CodeCoverage.php | 12 ++++++++++++ tests/tests/CodeCoverageTest.php | 27 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/CodeCoverage.php b/src/CodeCoverage.php index 6445c6d27..9df00af64 100644 --- a/src/CodeCoverage.php +++ b/src/CodeCoverage.php @@ -256,6 +256,8 @@ public function append(RawCodeCoverageData $rawData, $id = null, bool $append = $this->applyFilter($rawData); + $this->applyExecutableLinesFilter($rawData); + if ($this->useAnnotationsForIgnoringCode) { $this->applyIgnoredLinesFilter($rawData); } @@ -484,6 +486,16 @@ private function applyFilter(RawCodeCoverageData $data): void } } + private function applyExecutableLinesFilter(RawCodeCoverageData $data): void + { + foreach (array_keys($data->lineCoverage()) as $filename) { + $data->keepCoverageDataOnlyForLines( + $filename, + $this->uncoveredFileAnalyser()->executableLinesIn($filename) + ); + } + } + private function applyIgnoredLinesFilter(RawCodeCoverageData $data): void { foreach (array_keys($data->lineCoverage()) as $filename) { diff --git a/tests/tests/CodeCoverageTest.php b/tests/tests/CodeCoverageTest.php index 14df3f824..b957d2400 100644 --- a/tests/tests/CodeCoverageTest.php +++ b/tests/tests/CodeCoverageTest.php @@ -93,6 +93,33 @@ public function testWhitelistFiltering(): void $this->assertNotContains(TEST_FILES_PATH . 'CoverageClassTest.php', $this->coverage->getData()->coveredFiles()); } + public function testExcludeNonExecutableLines(): void + { + $this->coverage->filter()->includeFile(TEST_FILES_PATH . 'BankAccount.php'); + + $data = RawCodeCoverageData::fromXdebugWithoutPathCoverage([ + TEST_FILES_PATH . 'BankAccount.php' => array_fill(1, 100, -1), + ]); + + $this->coverage->append($data, 'A test', true); + + $expectedLineCoverage = [ + TEST_FILES_PATH . 'BankAccount.php' => [ + 8 => [], + 13 => [], + 14 => [], + 15 => [], + 16 => [], + 22 => [], + 24 => [], + 29 => [], + 31 => [], + ], + ]; + + $this->assertEquals($expectedLineCoverage, $this->coverage->getData()->lineCoverage()); + } + public function testMerge(): void { $coverage = $this->getLineCoverageForBankAccountForFirstTwoTests(); From ea7bbe090254127009a7b44d79c150e68ea29551 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Wed, 9 Feb 2022 15:39:04 +0100 Subject: [PATCH 02/10] ExecutableLinesFindingVisitor: mirror xDebug/PCOV behavior --- .../ExecutableLinesFindingVisitor.php | 6 +++- .../_files/source_with_heavy_indentation.php | 32 +++++++++++++++++++ tests/tests/RawCodeCoverageDataTest.php | 19 +++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tests/_files/source_with_heavy_indentation.php diff --git a/src/StaticAnalysis/ExecutableLinesFindingVisitor.php b/src/StaticAnalysis/ExecutableLinesFindingVisitor.php index 32205692d..416f576d6 100644 --- a/src/StaticAnalysis/ExecutableLinesFindingVisitor.php +++ b/src/StaticAnalysis/ExecutableLinesFindingVisitor.php @@ -12,6 +12,8 @@ use function array_unique; use function sort; use PhpParser\Node; +use PhpParser\Node\Expr\BinaryOp; +use PhpParser\Node\Expr\CallLike; use PhpParser\Node\Stmt\Break_; use PhpParser\Node\Stmt\Case_; use PhpParser\Node\Stmt\Catch_; @@ -67,7 +69,9 @@ public function executableLines(): array private function isExecutable(Node $node): bool { - return $node instanceof Break_ || + return $node instanceof BinaryOp || + $node instanceof Break_ || + $node instanceof CallLike || $node instanceof Case_ || $node instanceof Catch_ || $node instanceof Continue_ || diff --git a/tests/_files/source_with_heavy_indentation.php b/tests/_files/source_with_heavy_indentation.php new file mode 100644 index 000000000..0a0d4cbb8 --- /dev/null +++ b/tests/_files/source_with_heavy_indentation.php @@ -0,0 +1,32 @@ +state + or ( + $this->isBar() + and \in_array($this->state, [ + AType::A, + AType::B, + ], true) + ) + or (\in_array($this->type, [BType::X, BType::Y], true) + and \in_array($this->state, [ + AType::C, + AType::D, + AType::toOutput($this->state), + ], true)) + ; + } + + public function isTwo(): bool + { + return \in_array($this->state, [ + AType::A, + AType::B, + ], true); + } +} diff --git a/tests/tests/RawCodeCoverageDataTest.php b/tests/tests/RawCodeCoverageDataTest.php index 9c0b554e6..e8d958d15 100644 --- a/tests/tests/RawCodeCoverageDataTest.php +++ b/tests/tests/RawCodeCoverageDataTest.php @@ -321,6 +321,25 @@ public function testInlineCommentsKeepTheLine(): void ); } + public function testHeavyIndentationIsHandledCorrectly(): void + { + $file = TEST_FILES_PATH . 'source_with_heavy_indentation.php'; + + $this->assertEquals( + [ + 7, + 8, + 10, + 11, + 16, + 17, + 20, + 27, + ], + array_keys(RawCodeCoverageData::fromUncoveredFile($file, new ParsingUncoveredFileAnalyser)->lineCoverage()[$file]) + ); + } + public function testCoverageForFileWithInlineAnnotations(): void { $filename = TEST_FILES_PATH . 'source_with_oneline_annotations.php'; From 4520d9d84e23dd040cacb8c25ca073fad1507d49 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Wed, 9 Feb 2022 16:17:45 +0100 Subject: [PATCH 03/10] Executable lines differ a lot between standard and path coverage: filter lines only for standard one --- src/CodeCoverage.php | 5 +++-- src/RawCodeCoverageData.php | 28 ++++++++++++++++--------- tests/tests/RawCodeCoverageDataTest.php | 6 +++--- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/CodeCoverage.php b/src/CodeCoverage.php index 9df00af64..992d6c92c 100644 --- a/src/CodeCoverage.php +++ b/src/CodeCoverage.php @@ -468,7 +468,8 @@ private function applyCoversAnnotationFilter(RawCodeCoverageData $rawData, $line if (is_array($linesToBeCovered)) { foreach ($linesToBeCovered as $fileToBeCovered => $includedLines) { - $rawData->keepCoverageDataOnlyForLines($fileToBeCovered, $includedLines); + $rawData->keepLineCoverageDataOnlyForLines($fileToBeCovered, $includedLines); + $rawData->keepFunctionCoverageDataOnlyForLines($fileToBeCovered, $includedLines); } } } @@ -489,7 +490,7 @@ private function applyFilter(RawCodeCoverageData $data): void private function applyExecutableLinesFilter(RawCodeCoverageData $data): void { foreach (array_keys($data->lineCoverage()) as $filename) { - $data->keepCoverageDataOnlyForLines( + $data->keepLineCoverageDataOnlyForLines( $filename, $this->uncoveredFileAnalyser()->executableLinesIn($filename) ); diff --git a/src/RawCodeCoverageData.php b/src/RawCodeCoverageData.php index ae5044ffe..606bd773f 100644 --- a/src/RawCodeCoverageData.php +++ b/src/RawCodeCoverageData.php @@ -126,7 +126,7 @@ public function removeCoverageDataForFile(string $filename): void /** * @param int[] $lines */ - public function keepCoverageDataOnlyForLines(string $filename, array $lines): void + public function keepLineCoverageDataOnlyForLines(string $filename, array $lines): void { if (!isset($this->lineCoverage[$filename])) { return; @@ -136,17 +136,25 @@ public function keepCoverageDataOnlyForLines(string $filename, array $lines): vo $this->lineCoverage[$filename], array_flip($lines) ); + } - if (isset($this->functionCoverage[$filename])) { - foreach ($this->functionCoverage[$filename] as $functionName => $functionData) { - foreach ($functionData['branches'] as $branchId => $branch) { - if (count(array_diff(range($branch['line_start'], $branch['line_end']), $lines)) > 0) { - unset($this->functionCoverage[$filename][$functionName]['branches'][$branchId]); + /** + * @param int[] $lines + */ + public function keepFunctionCoverageDataOnlyForLines(string $filename, array $lines): void + { + if (!isset($this->functionCoverage[$filename])) { + return; + } - foreach ($functionData['paths'] as $pathId => $path) { - if (in_array($branchId, $path['path'], true)) { - unset($this->functionCoverage[$filename][$functionName]['paths'][$pathId]); - } + foreach ($this->functionCoverage[$filename] as $functionName => $functionData) { + foreach ($functionData['branches'] as $branchId => $branch) { + if (count(array_diff(range($branch['line_start'], $branch['line_end']), $lines)) > 0) { + unset($this->functionCoverage[$filename][$functionName]['branches'][$branchId]); + + foreach ($functionData['paths'] as $pathId => $path) { + if (in_array($branchId, $path['path'], true)) { + unset($this->functionCoverage[$filename][$functionName]['paths'][$pathId]); } } } diff --git a/tests/tests/RawCodeCoverageDataTest.php b/tests/tests/RawCodeCoverageDataTest.php index e8d958d15..cd95c5029 100644 --- a/tests/tests/RawCodeCoverageDataTest.php +++ b/tests/tests/RawCodeCoverageDataTest.php @@ -211,9 +211,9 @@ public function testKeepCoverageDataOnlyForLines(): void $dataObject = RawCodeCoverageData::fromXdebugWithoutPathCoverage($lineDataFromDriver); - $dataObject->keepCoverageDataOnlyForLines('/some/path/SomeClass.php', [9, 13]); - $dataObject->keepCoverageDataOnlyForLines('/some/path/SomeOtherClass.php', [999]); - $dataObject->keepCoverageDataOnlyForLines('/some/path/AnotherClass.php', [28]); + $dataObject->keepLineCoverageDataOnlyForLines('/some/path/SomeClass.php', [9, 13]); + $dataObject->keepLineCoverageDataOnlyForLines('/some/path/SomeOtherClass.php', [999]); + $dataObject->keepLineCoverageDataOnlyForLines('/some/path/AnotherClass.php', [28]); $this->assertEquals($expectedFilterResult, $dataObject->lineCoverage()); } From 564916a81f864cda3e819be3177d2c96ac353cc2 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Wed, 9 Feb 2022 16:31:34 +0100 Subject: [PATCH 04/10] Update test suite to reflect new executable LoC requirements --- tests/TestCase.php | 8 -- tests/_files/BankAccount-clover-line.xml | 7 +- tests/_files/BankAccount-clover-path.xml | 7 +- tests/_files/BankAccount-cobertura-line.xml | 8 +- tests/_files/BankAccount-cobertura-path.xml | 8 +- tests/_files/BankAccount-text-line.txt | 14 +-- tests/_files/BankAccount-text-path.txt | 16 +-- tests/_files/BankAccount-text-summary.txt | 2 +- .../BankAccountWithUncovered-text-line.txt | 4 +- .../BankAccountWithoutUncovered-text-line.txt | 14 +-- tests/_files/NamespacedBankAccount-text.txt | 14 +-- .../BankAccount.php.html | 32 +++--- .../CoverageForBankAccount/dashboard.html | 6 +- .../HTML/CoverageForBankAccount/index.html | 24 ++--- .../index.html | 24 ++--- .../source_with_ignore.php.html | 12 +-- .../dashboard.html | 10 +- .../index.html | 64 +++++------ ...with_class_and_anonymous_function.php.html | 102 +++++++++--------- .../index.html | 4 +- .../source_without_namespace.php.html | 6 +- .../source_without_namespace.php_branch.html | 4 +- .../source_without_namespace.php_path.html | 4 +- .../dashboard.html | 10 +- .../index.html | 64 +++++------ ...with_class_and_anonymous_function.php.html | 102 +++++++++--------- .../index.html | 4 +- .../source_without_namespace.php.html | 6 +- .../source_without_namespace.php_branch.html | 4 +- .../source_without_namespace.php_path.html | 4 +- .../BankAccount.php.html | 30 +++--- .../BankAccount.php_branch.html | 22 ++-- .../BankAccount.php_path.html | 22 ++-- .../PathCoverageForBankAccount/index.html | 24 ++--- .../BankAccount.php.xml | 6 +- .../XML/CoverageForBankAccount/index.xml | 4 +- .../CoverageForFileWithIgnoredLines/index.xml | 4 +- .../source_with_ignore.php.xml | 2 +- .../index.xml | 12 +-- ..._with_class_and_anonymous_function.php.xml | 22 +--- .../index.xml | 12 +-- ..._with_class_and_anonymous_function.php.xml | 22 +--- .../class-with-anonymous-function-clover.xml | 13 +-- ...lass-with-anonymous-function-cobertura.xml | 18 +--- .../class-with-anonymous-function-crap4j.xml | 2 +- .../class-with-anonymous-function-text.txt | 14 +-- tests/_files/ignored-lines-clover.xml | 5 +- tests/_files/ignored-lines-cobertura.xml | 4 +- tests/_files/ignored-lines-text.txt | 6 +- tests/tests/BuilderTest.php | 12 +-- 50 files changed, 393 insertions(+), 451 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index aa2b010c5..ec841b82d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1346,12 +1346,10 @@ protected function getExpectedLineCoverageDataArrayForBankAccount(): array 0 => 'BankAccountTest::testBalanceIsInitiallyZero', 1 => 'BankAccountTest::testDepositWithdrawMoney', ], - 9 => null, 13 => [], 14 => [], 15 => [], 16 => [], - 18 => [], 22 => [ 0 => 'BankAccountTest::testBalanceCannotBecomeNegative2', 1 => 'BankAccountTest::testDepositWithdrawMoney', @@ -1359,7 +1357,6 @@ protected function getExpectedLineCoverageDataArrayForBankAccount(): array 24 => [ 0 => 'BankAccountTest::testDepositWithdrawMoney', ], - 25 => null, 29 => [ 0 => 'BankAccountTest::testBalanceCannotBecomeNegative', 1 => 'BankAccountTest::testDepositWithdrawMoney', @@ -1367,7 +1364,6 @@ protected function getExpectedLineCoverageDataArrayForBankAccount(): array 31 => [ 0 => 'BankAccountTest::testDepositWithdrawMoney', ], - 32 => null, ], ]; } @@ -1380,12 +1376,10 @@ protected function getExpectedLineCoverageDataArrayForBankAccountInReverseOrder( 0 => 'BankAccountTest::testDepositWithdrawMoney', 1 => 'BankAccountTest::testBalanceIsInitiallyZero', ], - 9 => null, 13 => [], 14 => [], 15 => [], 16 => [], - 18 => [], 22 => [ 0 => 'BankAccountTest::testBalanceCannotBecomeNegative2', 1 => 'BankAccountTest::testDepositWithdrawMoney', @@ -1393,7 +1387,6 @@ protected function getExpectedLineCoverageDataArrayForBankAccountInReverseOrder( 24 => [ 0 => 'BankAccountTest::testDepositWithdrawMoney', ], - 25 => null, 29 => [ 0 => 'BankAccountTest::testDepositWithdrawMoney', 1 => 'BankAccountTest::testBalanceCannotBecomeNegative', @@ -1401,7 +1394,6 @@ protected function getExpectedLineCoverageDataArrayForBankAccountInReverseOrder( 31 => [ 0 => 'BankAccountTest::testDepositWithdrawMoney', ], - 32 => null, ], ]; } diff --git a/tests/_files/BankAccount-clover-line.xml b/tests/_files/BankAccount-clover-line.xml index 2f11d819c..b5bcf83dc 100644 --- a/tests/_files/BankAccount-clover-line.xml +++ b/tests/_files/BankAccount-clover-line.xml @@ -3,7 +3,7 @@ - + @@ -12,15 +12,14 @@ - - + - + diff --git a/tests/_files/BankAccount-clover-path.xml b/tests/_files/BankAccount-clover-path.xml index fe7cfe602..897bccfda 100644 --- a/tests/_files/BankAccount-clover-path.xml +++ b/tests/_files/BankAccount-clover-path.xml @@ -3,7 +3,7 @@ - + @@ -12,15 +12,14 @@ - - + - + diff --git a/tests/_files/BankAccount-cobertura-line.xml b/tests/_files/BankAccount-cobertura-line.xml index 702544c31..665760058 100644 --- a/tests/_files/BankAccount-cobertura-line.xml +++ b/tests/_files/BankAccount-cobertura-line.xml @@ -1,13 +1,13 @@ - + %s - + - + @@ -20,7 +20,6 @@ - @@ -42,7 +41,6 @@ - diff --git a/tests/_files/BankAccount-cobertura-path.xml b/tests/_files/BankAccount-cobertura-path.xml index 9f8ac5e37..b57c03148 100644 --- a/tests/_files/BankAccount-cobertura-path.xml +++ b/tests/_files/BankAccount-cobertura-path.xml @@ -1,13 +1,13 @@ - + %s - + - + @@ -20,7 +20,6 @@ - @@ -42,7 +41,6 @@ - diff --git a/tests/_files/BankAccount-text-line.txt b/tests/_files/BankAccount-text-line.txt index 892d83464..133c73797 100644 --- a/tests/_files/BankAccount-text-line.txt +++ b/tests/_files/BankAccount-text-line.txt @@ -1,12 +1,12 @@ -Code Coverage Report: +Code Coverage Report: %s - - Summary: - Classes: 0.00% (0/1) - Methods: 75.00% (3/4) - Lines: 50.00% (5/10) + + Summary: + Classes: 0.00% (0/1) + Methods: 75.00% (3/4) + Lines: 55.56% (5/9) BankAccount - Methods: 75.00% ( 3/ 4) Lines: 50.00% ( 5/ 10) + Methods: 75.00% ( 3/ 4) Lines: 55.56% ( 5/ 9) diff --git a/tests/_files/BankAccount-text-path.txt b/tests/_files/BankAccount-text-path.txt index d39487148..653f9ffed 100644 --- a/tests/_files/BankAccount-text-path.txt +++ b/tests/_files/BankAccount-text-path.txt @@ -1,14 +1,14 @@ -Code Coverage Report: +Code Coverage Report: %s - - Summary: - Classes: 0.00% (0/1) - Methods: 75.00% (3/4) - Paths: 60.00% (3/5) + + Summary: + Classes: 0.00% (0/1) + Methods: 75.00% (3/4) + Paths: 60.00% (3/5) Branches: 42.86% (3/7) - Lines: 50.00% (5/10) + Lines: 55.56% (5/9) BankAccount - Methods: 75.00% ( 3/ 4) Paths: 60.00% ( 3/ 5) Branches: 42.86% ( 3/ 7) Lines: 50.00% ( 5/ 10) + Methods: 75.00% ( 3/ 4) Paths: 60.00% ( 3/ 5) Branches: 42.86% ( 3/ 7) Lines: 55.56% ( 5/ 9) diff --git a/tests/_files/BankAccount-text-summary.txt b/tests/_files/BankAccount-text-summary.txt index c0fb9cc7d..96390c4cd 100644 --- a/tests/_files/BankAccount-text-summary.txt +++ b/tests/_files/BankAccount-text-summary.txt @@ -3,5 +3,5 @@ Code Coverage Report Summary: Classes: 0.00% (0/1) Methods: 75.00% (3/4) - Lines: 50.00% (5/10) + Lines: 55.56% (5/9) diff --git a/tests/_files/BankAccountWithUncovered-text-line.txt b/tests/_files/BankAccountWithUncovered-text-line.txt index c80e703db..4193b5ec7 100644 --- a/tests/_files/BankAccountWithUncovered-text-line.txt +++ b/tests/_files/BankAccountWithUncovered-text-line.txt @@ -6,7 +6,7 @@ Code Coverage Report: Summary: Classes: 0.00% (0/2) Methods: 37.50% (3/8) - Lines: 26.32% (5/19) + Lines: 27.78% (5/18) BankAccount - Methods: 75.00% ( 3/ 4) Lines: 50.00% ( 5/ 10) + Methods: 75.00% ( 3/ 4) Lines: 55.56% ( 5/ 9) diff --git a/tests/_files/BankAccountWithoutUncovered-text-line.txt b/tests/_files/BankAccountWithoutUncovered-text-line.txt index 892d83464..133c73797 100644 --- a/tests/_files/BankAccountWithoutUncovered-text-line.txt +++ b/tests/_files/BankAccountWithoutUncovered-text-line.txt @@ -1,12 +1,12 @@ -Code Coverage Report: +Code Coverage Report: %s - - Summary: - Classes: 0.00% (0/1) - Methods: 75.00% (3/4) - Lines: 50.00% (5/10) + + Summary: + Classes: 0.00% (0/1) + Methods: 75.00% (3/4) + Lines: 55.56% (5/9) BankAccount - Methods: 75.00% ( 3/ 4) Lines: 50.00% ( 5/ 10) + Methods: 75.00% ( 3/ 4) Lines: 55.56% ( 5/ 9) diff --git a/tests/_files/NamespacedBankAccount-text.txt b/tests/_files/NamespacedBankAccount-text.txt index 612512661..4cd9eb18f 100644 --- a/tests/_files/NamespacedBankAccount-text.txt +++ b/tests/_files/NamespacedBankAccount-text.txt @@ -1,14 +1,14 @@ -Code Coverage Report: +Code Coverage Report: %s - - Summary: - Classes: 0.00% (0/1) - Methods: 75.00% (3/4) - Lines: 50.00% (5/10) + + Summary: + Classes: 0.00% (0/1) + Methods: 75.00% (3/4) + Lines: 55.56% (5/9) SomeNamespace\BankAccount Methods: ( 0/ 0) Lines: ( 0/ 0) SomeNamespace\BankAccountTrait - Methods: 75.00% ( 3/ 4) Lines: 50.00% ( 5/ 10) + Methods: 75.00% ( 3/ 4) Lines: 55.56% ( 5/ 9) diff --git a/tests/_files/Report/HTML/CoverageForBankAccount/BankAccount.php.html b/tests/_files/Report/HTML/CoverageForBankAccount/BankAccount.php.html index 646035749..9f99ebc34 100644 --- a/tests/_files/Report/HTML/CoverageForBankAccount/BankAccount.php.html +++ b/tests/_files/Report/HTML/CoverageForBankAccount/BankAccount.php.html @@ -60,14 +60,14 @@
75.00%
3 / 4
CRAP -
-
- 50.00% covered (danger) +
+
+ 55.56% covered (warning)
-
50.00%
-
5 / 10
+
55.56%
+
5 / 9
@@ -88,15 +88,15 @@
75.00%
3 / 4
- 8.12 -
-
- 50.00% covered (danger) + 7.19 +
+
+ 55.56% covered (warning)
-
50.00%
-
5 / 10
+
55.56%
+
5 / 9
@@ -138,7 +138,7 @@
0.00%
-
0 / 5
+
0 / 4
@@ -197,7 +197,7 @@ 6    public function getBalance() 7    { 8        return $this->balance; - 9    } + 9    } 10 11    protected function setBalance($balance) 12    { @@ -206,21 +206,21 @@ 15        } else { 16            throw new RuntimeException; 17        } - 18    } + 18    } 19 20    public function depositMoney($balance) 21    { 22        $this->setBalance($this->getBalance() + $balance); 23 24        return $this->getBalance(); - 25    } + 25    } 26 27    public function withdrawMoney($balance) 28    { 29        $this->setBalance($this->getBalance() - $balance); 30 31        return $this->getBalance(); - 32    } + 32    } 33} diff --git a/tests/_files/Report/HTML/CoverageForBankAccount/dashboard.html b/tests/_files/Report/HTML/CoverageForBankAccount/dashboard.html index e47929fbd..fc20fb36e 100644 --- a/tests/_files/Report/HTML/CoverageForBankAccount/dashboard.html +++ b/tests/_files/Report/HTML/CoverageForBankAccount/dashboard.html @@ -57,7 +57,7 @@

Insufficient Coverage

- BankAccount50% + BankAccount55% @@ -74,7 +74,7 @@

Project Risks

- BankAccount8 + BankAccount7 @@ -226,7 +226,7 @@

Project Risks

chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[50,5,"BankAccount<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[55.555555555556,5,"BankAccount<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); diff --git a/tests/_files/Report/HTML/CoverageForBankAccount/index.html b/tests/_files/Report/HTML/CoverageForBankAccount/index.html index e0c9ed9d9..89ab27d54 100644 --- a/tests/_files/Report/HTML/CoverageForBankAccount/index.html +++ b/tests/_files/Report/HTML/CoverageForBankAccount/index.html @@ -42,15 +42,15 @@ - Total -
-
- 50.00% covered (danger) + Total +
+
+ 55.56% covered (warning)
-
50.00%
-
5 / 10
+
55.56%
+
5 / 9
75.00% covered (warning) @@ -70,15 +70,15 @@ - BankAccount.php -
-
- 50.00% covered (danger) + BankAccount.php +
+
+ 55.56% covered (warning)
-
50.00%
-
5 / 10
+
55.56%
+
5 / 9
75.00% covered (warning) diff --git a/tests/_files/Report/HTML/CoverageForFileWithIgnoredLines/index.html b/tests/_files/Report/HTML/CoverageForFileWithIgnoredLines/index.html index 7d4cfffce..99192670d 100644 --- a/tests/_files/Report/HTML/CoverageForFileWithIgnoredLines/index.html +++ b/tests/_files/Report/HTML/CoverageForFileWithIgnoredLines/index.html @@ -42,15 +42,15 @@ - Total -
-
- 50.00% covered (danger) + Total +
+
+ 100.00% covered (success)
-
50.00%
-
1 / 2
+
100.00%
+
1 / 1
100.00% covered (success) @@ -65,15 +65,15 @@ - source_with_ignore.php -
-
- 50.00% covered (danger) + source_with_ignore.php +
+
+ 100.00% covered (success)
-
50.00%
-
1 / 2
+
100.00%
+
1 / 1
100.00% covered (success) diff --git a/tests/_files/Report/HTML/CoverageForFileWithIgnoredLines/source_with_ignore.php.html b/tests/_files/Report/HTML/CoverageForFileWithIgnoredLines/source_with_ignore.php.html index d1218e2eb..58f568164 100644 --- a/tests/_files/Report/HTML/CoverageForFileWithIgnoredLines/source_with_ignore.php.html +++ b/tests/_files/Report/HTML/CoverageForFileWithIgnoredLines/source_with_ignore.php.html @@ -55,14 +55,14 @@
100.00%
1 / 1
CRAP -
-
- 50.00% covered (danger) +
+
+ 100.00% covered (success)
-
50.00%
-
1 / 2
+
100.00%
+
1 / 1
@@ -137,7 +137,7 @@ 3    // @codeCoverageIgnoreStart 4    print '*'; 5    // @codeCoverageIgnoreEnd - 6} + 6} 7 8/** 9 * @codeCoverageIgnore diff --git a/tests/_files/Report/HTML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/dashboard.html b/tests/_files/Report/HTML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/dashboard.html index c1246a182..6d77bc849 100644 --- a/tests/_files/Report/HTML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/dashboard.html +++ b/tests/_files/Report/HTML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/dashboard.html @@ -57,7 +57,6 @@

Insufficient Coverage

- CoveredClassWithAnonymousFunctionInStaticMethod88% @@ -111,7 +110,6 @@

Insufficient Coverage

- runAnonymous88% @@ -156,7 +154,7 @@

Project Risks

.yAxis.tickFormat(d3.format('d')); d3.select('#classCoverageDistribution svg') - .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,1,0,0], "Class Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,0,0,1], "Class Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -174,7 +172,7 @@

Project Risks

.yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,1,0,0], "Method Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,0,0,1], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -224,7 +222,7 @@

Project Risks

chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[88.888888888889,1,"CoveredClassWithAnonymousFunctionInStaticMethod<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[100,1,"CoveredClassWithAnonymousFunctionInStaticMethod<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -248,7 +246,7 @@

Project Risks

chart.yAxis.axisLabel('Method Complexity'); d3.select('#methodComplexity svg') - .datum(getComplexityData([[88.888888888889,1,"
CoveredClassWithAnonymousFunctionInStaticMethod::runAnonymous<\/a>"]], 'Method Complexity')) + .datum(getComplexityData([[100,1,"CoveredClassWithAnonymousFunctionInStaticMethod::runAnonymous<\/a>"]], 'Method Complexity')) .transition() .duration(500) .call(chart); diff --git a/tests/_files/Report/HTML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/index.html b/tests/_files/Report/HTML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/index.html index 222cec8c4..9626a7eea 100644 --- a/tests/_files/Report/HTML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/index.html +++ b/tests/_files/Report/HTML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/index.html @@ -42,59 +42,59 @@ - Total -
-
- 88.89% covered (warning) + Total +
+
+ 100.00% covered (success)
-
88.89%
-
8 / 9
-
-
- 0.00% covered (danger) +
100.00%
+
4 / 4
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
-
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
+
100.00%
+
1 / 1
-
source_with_class_and_anonymous_function.php -
-
- 88.89% covered (warning) + source_with_class_and_anonymous_function.php +
+
+ 100.00% covered (success)
-
88.89%
-
8 / 9
-
-
- 0.00% covered (danger) +
100.00%
+
4 / 4
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
-
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
+
100.00%
+
1 / 1
diff --git a/tests/_files/Report/HTML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.html b/tests/_files/Report/HTML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.html index e0a83a0a3..bbae23992 100644 --- a/tests/_files/Report/HTML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.html +++ b/tests/_files/Report/HTML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.html @@ -42,82 +42,82 @@ - Total -
-
- 0.00% covered (danger) + Total +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
-
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- CRAP -
-
- 88.89% covered (warning) +
100.00%
+
1 / 1
+ CRAP +
+
+ 100.00% covered (success)
-
88.89%
-
8 / 9
+
100.00%
+
4 / 4
- CoveredClassWithAnonymousFunctionInStaticMethod -
-
- 0.00% covered (danger) + CoveredClassWithAnonymousFunctionInStaticMethod +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
-
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 1.00 -
-
- 88.89% covered (warning) +
100.00%
+
1 / 1
+ 1 +
+
+ 100.00% covered (success)
-
88.89%
-
8 / 9
+
100.00%
+
4 / 4
-  runAnonymous -
-
- 0.00% covered (danger) +  runAnonymous +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 1.00 -
-
- 88.89% covered (warning) +
100.00%
+
1 / 1
+ 1 +
+
+ 100.00% covered (success)
-
88.89%
-
8 / 9
+
100.00%
+
4 / 4
@@ -135,15 +135,15 @@ 7        $filter = ['abc124', 'abc123', '123']; 8 9        array_walk( - 10            $filter, - 11            function (&$val, $key) { + 10            $filter, + 11            function (&$val, $key) { 12                $val = preg_replace('|[^0-9]|', '', $val); - 13            } - 14        ); + 13            } + 14        ); 15 16        // Should be covered 17        $extravar = true; - 18    } + 18    } 19} diff --git a/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/index.html b/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/index.html index b60a7d65b..72607caaf 100644 --- a/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/index.html +++ b/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/index.html @@ -52,7 +52,7 @@
0.00%
-
0 / 5
+
0 / 4
0.00% covered (danger) @@ -91,7 +91,7 @@
0.00%
-
0 / 5
+
0 / 4
0.00% covered (danger) diff --git a/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/source_without_namespace.php.html b/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/source_without_namespace.php.html index c0105b162..d82da91c5 100644 --- a/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/source_without_namespace.php.html +++ b/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/source_without_namespace.php.html @@ -80,7 +80,7 @@
0.00%
-
0 / 5
+
0 / 4
@@ -117,7 +117,7 @@
0.00%
-
0 / 5
+
0 / 4
@@ -163,7 +163,7 @@ 15    $a   = true ? true : false; 16    $b   = "{$a}"; 17    $c   = "${b}"; - 18} + 18} diff --git a/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_branch.html b/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_branch.html index 2fbee3406..a95fbb002 100644 --- a/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_branch.html +++ b/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_branch.html @@ -80,7 +80,7 @@
0.00%
-
0 / 5
+
0 / 4
@@ -117,7 +117,7 @@
0.00%
-
0 / 5
+
0 / 4
diff --git a/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_path.html b/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_path.html index aa088747f..c54d785b3 100644 --- a/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_path.html +++ b/tests/_files/Report/HTML/PHP80AndBelow/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_path.html @@ -80,7 +80,7 @@
0.00%
-
0 / 5
+
0 / 4
@@ -117,7 +117,7 @@
0.00%
-
0 / 5
+
0 / 4
diff --git a/tests/_files/Report/HTML/PHP81AndUp/CoverageForClassWithAnonymousFunction/dashboard.html b/tests/_files/Report/HTML/PHP81AndUp/CoverageForClassWithAnonymousFunction/dashboard.html index c1246a182..6d77bc849 100644 --- a/tests/_files/Report/HTML/PHP81AndUp/CoverageForClassWithAnonymousFunction/dashboard.html +++ b/tests/_files/Report/HTML/PHP81AndUp/CoverageForClassWithAnonymousFunction/dashboard.html @@ -57,7 +57,6 @@

Insufficient Coverage

- CoveredClassWithAnonymousFunctionInStaticMethod88% @@ -111,7 +110,6 @@

Insufficient Coverage

- runAnonymous88% @@ -156,7 +154,7 @@

Project Risks

.yAxis.tickFormat(d3.format('d')); d3.select('#classCoverageDistribution svg') - .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,1,0,0], "Class Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,0,0,1], "Class Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -174,7 +172,7 @@

Project Risks

.yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,1,0,0], "Method Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,0,0,1], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -224,7 +222,7 @@

Project Risks

chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[88.888888888889,1,"CoveredClassWithAnonymousFunctionInStaticMethod<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[100,1,"CoveredClassWithAnonymousFunctionInStaticMethod<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -248,7 +246,7 @@

Project Risks

chart.yAxis.axisLabel('Method Complexity'); d3.select('#methodComplexity svg') - .datum(getComplexityData([[88.888888888889,1,"
CoveredClassWithAnonymousFunctionInStaticMethod::runAnonymous<\/a>"]], 'Method Complexity')) + .datum(getComplexityData([[100,1,"CoveredClassWithAnonymousFunctionInStaticMethod::runAnonymous<\/a>"]], 'Method Complexity')) .transition() .duration(500) .call(chart); diff --git a/tests/_files/Report/HTML/PHP81AndUp/CoverageForClassWithAnonymousFunction/index.html b/tests/_files/Report/HTML/PHP81AndUp/CoverageForClassWithAnonymousFunction/index.html index 222cec8c4..9626a7eea 100644 --- a/tests/_files/Report/HTML/PHP81AndUp/CoverageForClassWithAnonymousFunction/index.html +++ b/tests/_files/Report/HTML/PHP81AndUp/CoverageForClassWithAnonymousFunction/index.html @@ -42,59 +42,59 @@ - Total -
-
- 88.89% covered (warning) + Total +
+
+ 100.00% covered (success)
-
88.89%
-
8 / 9
-
-
- 0.00% covered (danger) +
100.00%
+
4 / 4
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
-
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
+
100.00%
+
1 / 1
-
source_with_class_and_anonymous_function.php -
-
- 88.89% covered (warning) + source_with_class_and_anonymous_function.php +
+
+ 100.00% covered (success)
-
88.89%
-
8 / 9
-
-
- 0.00% covered (danger) +
100.00%
+
4 / 4
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
-
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
+
100.00%
+
1 / 1
diff --git a/tests/_files/Report/HTML/PHP81AndUp/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.html b/tests/_files/Report/HTML/PHP81AndUp/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.html index 72f19ae15..d1390f1e8 100644 --- a/tests/_files/Report/HTML/PHP81AndUp/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.html +++ b/tests/_files/Report/HTML/PHP81AndUp/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.html @@ -42,82 +42,82 @@ - Total -
-
- 0.00% covered (danger) + Total +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
-
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- CRAP -
-
- 88.89% covered (warning) +
100.00%
+
1 / 1
+ CRAP +
+
+ 100.00% covered (success)
-
88.89%
-
8 / 9
+
100.00%
+
4 / 4
- CoveredClassWithAnonymousFunctionInStaticMethod -
-
- 0.00% covered (danger) + CoveredClassWithAnonymousFunctionInStaticMethod +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
-
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 1.00 -
-
- 88.89% covered (warning) +
100.00%
+
1 / 1
+ 1 +
+
+ 100.00% covered (success)
-
88.89%
-
8 / 9
+
100.00%
+
4 / 4
-  runAnonymous -
-
- 0.00% covered (danger) +  runAnonymous +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 1.00 -
-
- 88.89% covered (warning) +
100.00%
+
1 / 1
+ 1 +
+
+ 100.00% covered (success)
-
88.89%
-
8 / 9
+
100.00%
+
4 / 4
@@ -135,15 +135,15 @@ 7        $filter = ['abc124', 'abc123', '123']; 8 9        array_walk( - 10            $filter, - 11            function (&$val, $key) { + 10            $filter, + 11            function (&$val, $key) { 12                $val = preg_replace('|[^0-9]|', '', $val); - 13            } - 14        ); + 13            } + 14        ); 15 16        // Should be covered 17        $extravar = true; - 18    } + 18    } 19} diff --git a/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/index.html b/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/index.html index b60a7d65b..72607caaf 100644 --- a/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/index.html +++ b/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/index.html @@ -52,7 +52,7 @@
0.00%
-
0 / 5
+
0 / 4
0.00% covered (danger) @@ -91,7 +91,7 @@
0.00%
-
0 / 5
+
0 / 4
0.00% covered (danger) diff --git a/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/source_without_namespace.php.html b/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/source_without_namespace.php.html index 163e982b9..aee66088a 100644 --- a/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/source_without_namespace.php.html +++ b/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/source_without_namespace.php.html @@ -80,7 +80,7 @@
0.00%
-
0 / 5
+
0 / 4
@@ -117,7 +117,7 @@
0.00%
-
0 / 5
+
0 / 4
@@ -163,7 +163,7 @@ 15    $a   = true ? true : false; 16    $b   = "{$a}"; 17    $c   = "${b}"; - 18} + 18} diff --git a/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_branch.html b/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_branch.html index 76857ba92..8368e45c0 100644 --- a/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_branch.html +++ b/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_branch.html @@ -80,7 +80,7 @@
0.00%
-
0 / 5
+
0 / 4
@@ -117,7 +117,7 @@
0.00%
-
0 / 5
+
0 / 4
diff --git a/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_path.html b/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_path.html index 9418bca07..543f5109d 100644 --- a/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_path.html +++ b/tests/_files/Report/HTML/PHP81AndUp/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_path.html @@ -80,7 +80,7 @@
0.00%
-
0 / 5
+
0 / 4
@@ -117,7 +117,7 @@
0.00%
-
0 / 5
+
0 / 4
diff --git a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html index 3847b4399..51aeefae6 100644 --- a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html +++ b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html @@ -78,14 +78,14 @@
42.86%
3 / 7
-
-
- 50.00% covered (danger) +
+
+ 55.56% covered (warning)
-
50.00%
-
5 / 10
+
55.56%
+
5 / 9
@@ -123,14 +123,14 @@
42.86%
3 / 7
-
-
- 50.00% covered (danger) +
+
+ 55.56% covered (warning)
-
50.00%
-
5 / 10
+
55.56%
+
5 / 9
@@ -204,7 +204,7 @@
0.00%
-
0 / 5
+
0 / 4
@@ -295,7 +295,7 @@ 6    public function getBalance() 7    { 8        return $this->balance; - 9    } + 9    } 10 11    protected function setBalance($balance) 12    { @@ -304,21 +304,21 @@ 15        } else { 16            throw new RuntimeException; 17        } - 18    } + 18    } 19 20    public function depositMoney($balance) 21    { 22        $this->setBalance($this->getBalance() + $balance); 23 24        return $this->getBalance(); - 25    } + 25    } 26 27    public function withdrawMoney($balance) 28    { 29        $this->setBalance($this->getBalance() - $balance); 30 31        return $this->getBalance(); - 32    } + 32    } 33} diff --git a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_branch.html b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_branch.html index 7815dc9e9..7d1bf5cc1 100644 --- a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_branch.html +++ b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_branch.html @@ -78,14 +78,14 @@
42.86%
3 / 7
-
-
- 50.00% covered (danger) +
+
+ 55.56% covered (warning)
-
50.00%
-
5 / 10
+
55.56%
+
5 / 9
@@ -123,14 +123,14 @@
42.86%
3 / 7
-
-
- 50.00% covered (danger) +
+
+ 55.56% covered (warning)
-
50.00%
-
5 / 10
+
55.56%
+
5 / 9
@@ -204,7 +204,7 @@
0.00%
-
0 / 5
+
0 / 4
diff --git a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html index 67cbe9943..d69dfdcae 100644 --- a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html +++ b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html @@ -78,14 +78,14 @@
42.86%
3 / 7
-
-
- 50.00% covered (danger) +
+
+ 55.56% covered (warning)
-
50.00%
-
5 / 10
+
55.56%
+
5 / 9
@@ -123,14 +123,14 @@
42.86%
3 / 7
-
-
- 50.00% covered (danger) +
+
+ 55.56% covered (warning)
-
50.00%
-
5 / 10
+
55.56%
+
5 / 9
@@ -204,7 +204,7 @@
0.00%
-
0 / 5
+
0 / 4
diff --git a/tests/_files/Report/HTML/PathCoverageForBankAccount/index.html b/tests/_files/Report/HTML/PathCoverageForBankAccount/index.html index 8400c9b4b..c31d0b7a7 100644 --- a/tests/_files/Report/HTML/PathCoverageForBankAccount/index.html +++ b/tests/_files/Report/HTML/PathCoverageForBankAccount/index.html @@ -44,15 +44,15 @@ - Total -
-
- 50.00% covered (danger) + Total +
+
+ 55.56% covered (warning)
-
50.00%
-
5 / 10
+
55.56%
+
5 / 9
42.86% covered (danger) @@ -88,15 +88,15 @@ - BankAccount.php [line] [branch] [path] -
-
- 50.00% covered (danger) + BankAccount.php [line] [branch] [path] +
+
+ 55.56% covered (warning)
-
50.00%
-
5 / 10
+
55.56%
+
5 / 9
42.86% covered (danger) diff --git a/tests/_files/Report/XML/CoverageForBankAccount/BankAccount.php.xml b/tests/_files/Report/XML/CoverageForBankAccount/BankAccount.php.xml index 577bc4cc9..a7db6aafd 100644 --- a/tests/_files/Report/XML/CoverageForBankAccount/BankAccount.php.xml +++ b/tests/_files/Report/XML/CoverageForBankAccount/BankAccount.php.xml @@ -2,16 +2,16 @@ - + - + - + diff --git a/tests/_files/Report/XML/CoverageForBankAccount/index.xml b/tests/_files/Report/XML/CoverageForBankAccount/index.xml index df433b085..ffc367113 100644 --- a/tests/_files/Report/XML/CoverageForBankAccount/index.xml +++ b/tests/_files/Report/XML/CoverageForBankAccount/index.xml @@ -13,7 +13,7 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/tests/_files/Report/XML/CoverageForFileWithIgnoredLines/index.xml b/tests/_files/Report/XML/CoverageForFileWithIgnoredLines/index.xml index 65c08f517..ff573b704 100644 --- a/tests/_files/Report/XML/CoverageForFileWithIgnoredLines/index.xml +++ b/tests/_files/Report/XML/CoverageForFileWithIgnoredLines/index.xml @@ -10,7 +10,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/tests/_files/Report/XML/CoverageForFileWithIgnoredLines/source_with_ignore.php.xml b/tests/_files/Report/XML/CoverageForFileWithIgnoredLines/source_with_ignore.php.xml index a2b6623b4..b4d163c63 100644 --- a/tests/_files/Report/XML/CoverageForFileWithIgnoredLines/source_with_ignore.php.xml +++ b/tests/_files/Report/XML/CoverageForFileWithIgnoredLines/source_with_ignore.php.xml @@ -2,7 +2,7 @@ - + diff --git a/tests/_files/Report/XML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/index.xml b/tests/_files/Report/XML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/index.xml index 0ae6bdea3..ad86c96f4 100644 --- a/tests/_files/Report/XML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/index.xml +++ b/tests/_files/Report/XML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/index.xml @@ -10,18 +10,18 @@ - - + + - + - - + + - + diff --git a/tests/_files/Report/XML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.xml b/tests/_files/Report/XML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.xml index 8757aa362..ab4f84275 100644 --- a/tests/_files/Report/XML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.xml +++ b/tests/_files/Report/XML/PHP80AndBelow/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.xml @@ -2,15 +2,15 @@ - - + + - + - + - + @@ -19,24 +19,12 @@ - - - - - - - - - - - - diff --git a/tests/_files/Report/XML/PHP81AndUp/CoverageForClassWithAnonymousFunction/index.xml b/tests/_files/Report/XML/PHP81AndUp/CoverageForClassWithAnonymousFunction/index.xml index 0ae6bdea3..ad86c96f4 100644 --- a/tests/_files/Report/XML/PHP81AndUp/CoverageForClassWithAnonymousFunction/index.xml +++ b/tests/_files/Report/XML/PHP81AndUp/CoverageForClassWithAnonymousFunction/index.xml @@ -10,18 +10,18 @@ - - + + - + - - + + - + diff --git a/tests/_files/Report/XML/PHP81AndUp/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.xml b/tests/_files/Report/XML/PHP81AndUp/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.xml index f4275cd8b..a767fa117 100644 --- a/tests/_files/Report/XML/PHP81AndUp/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.xml +++ b/tests/_files/Report/XML/PHP81AndUp/CoverageForClassWithAnonymousFunction/source_with_class_and_anonymous_function.php.xml @@ -2,15 +2,15 @@ - - + + - + - + - + @@ -19,24 +19,12 @@ - - - - - - - - - - - - diff --git a/tests/_files/class-with-anonymous-function-clover.xml b/tests/_files/class-with-anonymous-function-clover.xml index 785195405..223ebebec 100644 --- a/tests/_files/class-with-anonymous-function-clover.xml +++ b/tests/_files/class-with-anonymous-function-clover.xml @@ -3,20 +3,15 @@ - + - + - - - - - - + - + diff --git a/tests/_files/class-with-anonymous-function-cobertura.xml b/tests/_files/class-with-anonymous-function-cobertura.xml index fa7b8a2c4..874f85080 100644 --- a/tests/_files/class-with-anonymous-function-cobertura.xml +++ b/tests/_files/class-with-anonymous-function-cobertura.xml @@ -1,38 +1,28 @@ - + %s - + - + - + - - - - - - - - - - diff --git a/tests/_files/class-with-anonymous-function-crap4j.xml b/tests/_files/class-with-anonymous-function-crap4j.xml index 2d60e6215..11ace3eb9 100644 --- a/tests/_files/class-with-anonymous-function-crap4j.xml +++ b/tests/_files/class-with-anonymous-function-crap4j.xml @@ -19,7 +19,7 @@ runAnonymous() 1 1 - 88.89 + 100 0 diff --git a/tests/_files/class-with-anonymous-function-text.txt b/tests/_files/class-with-anonymous-function-text.txt index fc46ef929..ca6d0b965 100644 --- a/tests/_files/class-with-anonymous-function-text.txt +++ b/tests/_files/class-with-anonymous-function-text.txt @@ -1,12 +1,12 @@ -Code Coverage Report: +Code Coverage Report: %s - - Summary: - Classes: 0.00% (0/1) - Methods: 0.00% (0/1) - Lines: 88.89% (8/9) + + Summary: + Classes: 100.00% (1/1) + Methods: 100.00% (1/1) + Lines: 100.00% (4/4) CoveredClassWithAnonymousFunctionInStaticMethod - Methods: 0.00% ( 0/ 1) Lines: 88.89% ( 8/ 9) + Methods: 100.00% ( 1/ 1) Lines: 100.00% ( 4/ 4) diff --git a/tests/_files/ignored-lines-clover.xml b/tests/_files/ignored-lines-clover.xml index 0b619ef30..1341bf33d 100644 --- a/tests/_files/ignored-lines-clover.xml +++ b/tests/_files/ignored-lines-clover.xml @@ -9,9 +9,8 @@ - - + - + diff --git a/tests/_files/ignored-lines-cobertura.xml b/tests/_files/ignored-lines-cobertura.xml index e0f9c4c38..3ec411f67 100644 --- a/tests/_files/ignored-lines-cobertura.xml +++ b/tests/_files/ignored-lines-cobertura.xml @@ -1,11 +1,11 @@ - + %s - + diff --git a/tests/_files/ignored-lines-text.txt b/tests/_files/ignored-lines-text.txt index 6e8e1494f..55f57afbc 100644 --- a/tests/_files/ignored-lines-text.txt +++ b/tests/_files/ignored-lines-text.txt @@ -4,7 +4,7 @@ Code Coverage Report:%w %s %w Summary:%w - Classes: (0/0) - Methods: (0/0) - Lines: 50.00% (1/2) + Classes: (0/0) + Methods: (0/0) + Lines: 100.00% (1/1) diff --git a/tests/tests/BuilderTest.php b/tests/tests/BuilderTest.php index e91484c5c..75a209094 100644 --- a/tests/tests/BuilderTest.php +++ b/tests/tests/BuilderTest.php @@ -33,7 +33,7 @@ public function testSomething(): void $expectedPath = rtrim(TEST_FILES_PATH, DIRECTORY_SEPARATOR); $this->assertEquals($expectedPath, $root->name()); $this->assertEquals($expectedPath, $root->pathAsString()); - $this->assertEquals(10, $root->numberOfExecutableLines()); + $this->assertEquals(9, $root->numberOfExecutableLines()); $this->assertEquals(5, $root->numberOfExecutedLines()); $this->assertEquals(1, $root->numberOfClasses()); $this->assertEquals(0, $root->numberOfTestedClasses()); @@ -41,7 +41,7 @@ public function testSomething(): void $this->assertEquals(3, $root->numberOfTestedMethods()); $this->assertEquals('0.00%', $root->percentageOfTestedClasses()->asString()); $this->assertEquals('75.00%', $root->percentageOfTestedMethods()->asString()); - $this->assertEquals('50.00%', $root->percentageOfExecutedLines()->asString()); + $this->assertEquals('55.56%', $root->percentageOfExecutedLines()->asString()); $this->assertEquals(0, $root->numberOfFunctions()); $this->assertEquals(0, $root->numberOfTestedFunctions()); $this->assertNull($root->parent()); @@ -74,7 +74,7 @@ public function testSomething(): void 'signature' => 'setBalance($balance)', 'startLine' => 11, 'endLine' => 18, - 'executableLines' => 5, + 'executableLines' => 4, 'executedLines' => 0, 'executableBranches' => 0, 'executedBranches' => 0, @@ -123,15 +123,15 @@ public function testSomething(): void ], ], 'startLine' => 2, - 'executableLines' => 10, + 'executableLines' => 9, 'executedLines' => 5, 'executableBranches' => 0, 'executedBranches' => 0, 'executablePaths' => 0, 'executedPaths' => 0, 'ccn' => 5, - 'coverage' => 50, - 'crap' => '8.12', + 'coverage' => 55.555555555556, + 'crap' => '7.19', 'link' => 'BankAccount.php.html#2', 'className' => 'BankAccount', 'namespace' => '', From 91be05cb7e9b225b0456e95b99c789fd0d4406b4 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Thu, 10 Feb 2022 11:42:55 +0100 Subject: [PATCH 05/10] ExecutableLinesFindingVisitor: narrow match to actual xDebug/PCOV LoC filtering --- .../ExecutableLinesFindingVisitor.php | 46 ++++++++++++++++- .../_files/source_with_heavy_indentation.php | 51 +++++++++++++++++++ tests/tests/RawCodeCoverageDataTest.php | 28 +++++++--- 3 files changed, 117 insertions(+), 8 deletions(-) diff --git a/src/StaticAnalysis/ExecutableLinesFindingVisitor.php b/src/StaticAnalysis/ExecutableLinesFindingVisitor.php index 416f576d6..9f20ff761 100644 --- a/src/StaticAnalysis/ExecutableLinesFindingVisitor.php +++ b/src/StaticAnalysis/ExecutableLinesFindingVisitor.php @@ -14,6 +14,7 @@ use PhpParser\Node; use PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\CallLike; +use PhpParser\Node\Scalar; use PhpParser\Node\Stmt\Break_; use PhpParser\Node\Stmt\Case_; use PhpParser\Node\Stmt\Catch_; @@ -28,6 +29,7 @@ use PhpParser\Node\Stmt\Foreach_; use PhpParser\Node\Stmt\Goto_; use PhpParser\Node\Stmt\If_; +use PhpParser\Node\Stmt\Property; use PhpParser\Node\Stmt\Return_; use PhpParser\Node\Stmt\Switch_; use PhpParser\Node\Stmt\Throw_; @@ -46,13 +48,26 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract */ private $executableLines = []; + /** + * @psalm-var array + */ + private $propertyLines = []; + public function enterNode(Node $node): void { + $this->savePropertyLines($node); + if (!$this->isExecutable($node)) { return; } - $this->executableLines[] = $node->getStartLine(); + $line = $this->getLine($node); + + if (isset($this->propertyLines[$line])) { + return; + } + + $this->executableLines[] = $line; } /** @@ -67,6 +82,30 @@ public function executableLines(): array return $executableLines; } + private function savePropertyLines(Node $node): void + { + if (!$node instanceof Property && !$node instanceof Node\Stmt\ClassConst) { + return; + } + + foreach (range($node->getStartLine(), $node->getEndLine()) as $index) { + $this->propertyLines[$index] = $index; + } + } + + private function getLine(Node $node): int + { + if ( + $node instanceof Node\Expr\PropertyFetch || + $node instanceof Node\Expr\NullsafePropertyFetch || + $node instanceof Node\Expr\StaticPropertyFetch + ) { + return $node->getEndLine(); + } + + return $node->getStartLine(); + } + private function isExecutable(Node $node): bool { return $node instanceof BinaryOp || @@ -86,10 +125,15 @@ private function isExecutable(Node $node): bool $node instanceof Goto_ || $node instanceof If_ || $node instanceof Return_ || + $node instanceof Scalar || $node instanceof Switch_ || $node instanceof Throw_ || $node instanceof TryCatch || $node instanceof Unset_ || + $node instanceof Node\Expr\Assign || + $node instanceof Node\Expr\PropertyFetch || + $node instanceof Node\Expr\NullsafePropertyFetch || + $node instanceof Node\Expr\StaticPropertyFetch || $node instanceof While_; } } diff --git a/tests/_files/source_with_heavy_indentation.php b/tests/_files/source_with_heavy_indentation.php index 0a0d4cbb8..55f364f51 100644 --- a/tests/_files/source_with_heavy_indentation.php +++ b/tests/_files/source_with_heavy_indentation.php @@ -2,8 +2,16 @@ class Foo { + private $state = 1; + public function isOne(): bool { + $v3 + = + (bool) + AType::OPT + ; + return AType::A === $this->state or ( @@ -19,6 +27,46 @@ public function isOne(): bool AType::D, AType::toOutput($this->state), ], true)) + || + \in_array + ( + 1 + , + [ + AType::A + , + 2 + , + $v2 + = + PHP_INT_MAX + , + $this + -> + state + , + $v3 + = + 1 + => + 2 + , + uniqid() + => + true + , + $this + ?-> + state + , + self + :: + $state + ] + , + (bool) + AType::A + ) ; } @@ -29,4 +77,7 @@ public function isTwo(): bool AType::B, ], true); } + + private static $staticState = 1; + private const CONST_STATE = 1.1; } diff --git a/tests/tests/RawCodeCoverageDataTest.php b/tests/tests/RawCodeCoverageDataTest.php index cd95c5029..2939e995a 100644 --- a/tests/tests/RawCodeCoverageDataTest.php +++ b/tests/tests/RawCodeCoverageDataTest.php @@ -270,6 +270,7 @@ public function testUseStatementsAreUncovered(): void [ 12, 14, + 15, 18, ], array_keys(RawCodeCoverageData::fromUncoveredFile($file, new ParsingUncoveredFileAnalyser)->lineCoverage()[$file]) @@ -296,6 +297,7 @@ public function testInterfacesAreUncovered(): void [ 7, 9, + 10, 13, ], array_keys(RawCodeCoverageData::fromUncoveredFile($file, new ParsingUncoveredFileAnalyser)->lineCoverage()[$file]) @@ -327,14 +329,26 @@ public function testHeavyIndentationIsHandledCorrectly(): void $this->assertEquals( [ - 7, - 8, - 10, - 11, + 9, + 15, 16, - 17, - 20, - 27, + 18, + 19, + 24, + 25, + 28, + 31, + 33, + 38, + 40, + 46, + 48, + 50, + 52, + 54, + 60, + 64, + 75, ], array_keys(RawCodeCoverageData::fromUncoveredFile($file, new ParsingUncoveredFileAnalyser)->lineCoverage()[$file]) ); From 2f8bbbd1673245736ca883f956c14bdd59069baf Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Thu, 10 Feb 2022 11:47:20 +0100 Subject: [PATCH 06/10] Minor optimization --- .../ExecutableLinesFindingVisitor.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/StaticAnalysis/ExecutableLinesFindingVisitor.php b/src/StaticAnalysis/ExecutableLinesFindingVisitor.php index 9f20ff761..2121466bc 100644 --- a/src/StaticAnalysis/ExecutableLinesFindingVisitor.php +++ b/src/StaticAnalysis/ExecutableLinesFindingVisitor.php @@ -9,8 +9,6 @@ */ namespace SebastianBergmann\CodeCoverage\StaticAnalysis; -use function array_unique; -use function sort; use PhpParser\Node; use PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\CallLike; @@ -44,7 +42,7 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract { /** - * @psalm-var list + * @psalm-var array */ private $executableLines = []; @@ -67,19 +65,15 @@ public function enterNode(Node $node): void return; } - $this->executableLines[] = $line; + $this->executableLines[$line] = $line; } /** - * @psalm-return list + * @psalm-return array */ public function executableLines(): array { - $executableLines = array_unique($this->executableLines); - - sort($executableLines); - - return $executableLines; + return $this->executableLines; } private function savePropertyLines(Node $node): void From 07df4acd9c979736ddfdab63ccbdd7e5adb7e716 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Thu, 10 Feb 2022 11:49:58 +0100 Subject: [PATCH 07/10] CachingUncoveredFileAnalyser: ensure next release gets fresh cache --- src/StaticAnalysis/CachingUncoveredFileAnalyser.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/StaticAnalysis/CachingUncoveredFileAnalyser.php b/src/StaticAnalysis/CachingUncoveredFileAnalyser.php index f52bb3518..046004954 100644 --- a/src/StaticAnalysis/CachingUncoveredFileAnalyser.php +++ b/src/StaticAnalysis/CachingUncoveredFileAnalyser.php @@ -28,13 +28,15 @@ public function __construct(string $directory, UncoveredFileAnalyser $uncoveredF public function executableLinesIn(string $filename): array { - if ($this->has($filename, __METHOD__)) { - return $this->read($filename, __METHOD__); + $cacheKey = 'v2' . __METHOD__; + + if ($this->has($filename, $cacheKey)) { + return $this->read($filename, $cacheKey); } $data = $this->uncoveredFileAnalyser->executableLinesIn($filename); - $this->write($filename, __METHOD__, $data); + $this->write($filename, $cacheKey, $data); return $data; } From 4a9b10f82b8cf27924ce2e9f49ccfabe0496d36b Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Thu, 10 Feb 2022 16:22:29 +0100 Subject: [PATCH 08/10] Remove PHP 8.1 specific syntax from test suite --- tests/_files/source_with_heavy_indentation.php | 4 ---- tests/tests/RawCodeCoverageDataTest.php | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/_files/source_with_heavy_indentation.php b/tests/_files/source_with_heavy_indentation.php index 55f364f51..bf4b123af 100644 --- a/tests/_files/source_with_heavy_indentation.php +++ b/tests/_files/source_with_heavy_indentation.php @@ -55,10 +55,6 @@ public function isOne(): bool => true , - $this - ?-> - state - , self :: $state diff --git a/tests/tests/RawCodeCoverageDataTest.php b/tests/tests/RawCodeCoverageDataTest.php index 2939e995a..e0738e09f 100644 --- a/tests/tests/RawCodeCoverageDataTest.php +++ b/tests/tests/RawCodeCoverageDataTest.php @@ -347,8 +347,7 @@ public function testHeavyIndentationIsHandledCorrectly(): void 52, 54, 60, - 64, - 75, + 71, ], array_keys(RawCodeCoverageData::fromUncoveredFile($file, new ParsingUncoveredFileAnalyser)->lineCoverage()[$file]) ); From db5894ac51da2fdfc1654a11d5efcad569f10cf3 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Fri, 11 Feb 2022 09:59:05 +0100 Subject: [PATCH 09/10] Expand stub with an actual dead loc --- tests/TestCase.php | 6 ++++++ tests/_files/BankAccount-clover-line.xml | 4 ++-- tests/_files/BankAccount-clover-path.xml | 4 ++-- tests/_files/BankAccount.php | 1 + .../BankAccount.php.html | 5 +++-- .../BankAccount.php.xml | 19 +++++++++++++++---- .../XML/CoverageForBankAccount/index.xml | 4 ++-- tests/tests/BuilderTest.php | 2 +- tests/tests/CodeCoverageTest.php | 1 + 9 files changed, 33 insertions(+), 13 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index ec841b82d..905c3c53e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -45,6 +45,8 @@ protected function getLineCoverageXdebugDataForBankAccount() 29 => -1, 31 => -1, 32 => -2, + 33 => -2, + 35 => 1, ], ]), RawCodeCoverageData::fromXdebugWithoutPathCoverage([ @@ -59,6 +61,7 @@ protected function getLineCoverageXdebugDataForBankAccount() 29 => 1, 31 => -1, 32 => -2, + 33 => -2, ], ]), RawCodeCoverageData::fromXdebugWithoutPathCoverage([ @@ -90,6 +93,7 @@ protected function getLineCoverageXdebugDataForBankAccount() 29 => 1, 31 => 1, 32 => -2, + 33 => -2, ], ]), ]; @@ -1364,6 +1368,7 @@ protected function getExpectedLineCoverageDataArrayForBankAccount(): array 31 => [ 0 => 'BankAccountTest::testDepositWithdrawMoney', ], + 32 => null, ], ]; } @@ -1394,6 +1399,7 @@ protected function getExpectedLineCoverageDataArrayForBankAccountInReverseOrder( 31 => [ 0 => 'BankAccountTest::testDepositWithdrawMoney', ], + 32 => null, ], ]; } diff --git a/tests/_files/BankAccount-clover-line.xml b/tests/_files/BankAccount-clover-line.xml index b5bcf83dc..07afc5b8c 100644 --- a/tests/_files/BankAccount-clover-line.xml +++ b/tests/_files/BankAccount-clover-line.xml @@ -18,8 +18,8 @@ - + - + diff --git a/tests/_files/BankAccount-clover-path.xml b/tests/_files/BankAccount-clover-path.xml index 897bccfda..b441efcfc 100644 --- a/tests/_files/BankAccount-clover-path.xml +++ b/tests/_files/BankAccount-clover-path.xml @@ -18,8 +18,8 @@ - + - + diff --git a/tests/_files/BankAccount.php b/tests/_files/BankAccount.php index 4238c1559..70f4ed78e 100644 --- a/tests/_files/BankAccount.php +++ b/tests/_files/BankAccount.php @@ -29,5 +29,6 @@ public function withdrawMoney($balance) $this->setBalance($this->getBalance() - $balance); return $this->getBalance(); + return $this->getBalance(); } } diff --git a/tests/_files/Report/HTML/CoverageForBankAccount/BankAccount.php.html b/tests/_files/Report/HTML/CoverageForBankAccount/BankAccount.php.html index 9f99ebc34..05078012d 100644 --- a/tests/_files/Report/HTML/CoverageForBankAccount/BankAccount.php.html +++ b/tests/_files/Report/HTML/CoverageForBankAccount/BankAccount.php.html @@ -220,8 +220,9 @@ 29        $this->setBalance($this->getBalance() - $balance); 30 31        return $this->getBalance(); - 32    } - 33} + 32        return $this->getBalance(); + 33    } + 34} diff --git a/tests/_files/Report/XML/CoverageForBankAccount/BankAccount.php.xml b/tests/_files/Report/XML/CoverageForBankAccount/BankAccount.php.xml index a7db6aafd..0731a8335 100644 --- a/tests/_files/Report/XML/CoverageForBankAccount/BankAccount.php.xml +++ b/tests/_files/Report/XML/CoverageForBankAccount/BankAccount.php.xml @@ -2,7 +2,7 @@ - + @@ -13,7 +13,7 @@ - + @@ -249,13 +249,24 @@ ; + + return + + $this + -> + getBalance + ( + ) + ; + + } - + } - + diff --git a/tests/_files/Report/XML/CoverageForBankAccount/index.xml b/tests/_files/Report/XML/CoverageForBankAccount/index.xml index ffc367113..b8d20f33e 100644 --- a/tests/_files/Report/XML/CoverageForBankAccount/index.xml +++ b/tests/_files/Report/XML/CoverageForBankAccount/index.xml @@ -13,7 +13,7 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/tests/tests/BuilderTest.php b/tests/tests/BuilderTest.php index 75a209094..18399d641 100644 --- a/tests/tests/BuilderTest.php +++ b/tests/tests/BuilderTest.php @@ -107,7 +107,7 @@ public function testSomething(): void 'withdrawMoney' => [ 'signature' => 'withdrawMoney($balance)', 'startLine' => 27, - 'endLine' => 32, + 'endLine' => 33, 'executableLines' => 2, 'executedLines' => 2, 'executableBranches' => 0, diff --git a/tests/tests/CodeCoverageTest.php b/tests/tests/CodeCoverageTest.php index b957d2400..8de789819 100644 --- a/tests/tests/CodeCoverageTest.php +++ b/tests/tests/CodeCoverageTest.php @@ -114,6 +114,7 @@ public function testExcludeNonExecutableLines(): void 24 => [], 29 => [], 31 => [], + 32 => [], ], ]; From ebe3dc99eb88b38f3c742902e9d0f82d406075bd Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Tue, 15 Feb 2022 10:12:09 +0100 Subject: [PATCH 10/10] Adapt HTML branch/path tests --- .../BankAccount.php.html | 5 ++-- .../BankAccount.php_branch.html | 24 ++++--------------- .../BankAccount.php_path.html | 22 +++-------------- 3 files changed, 10 insertions(+), 41 deletions(-) diff --git a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html index 51aeefae6..60f633a9b 100644 --- a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html +++ b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html @@ -318,8 +318,9 @@ 29        $this->setBalance($this->getBalance() - $balance); 30 31        return $this->getBalance(); - 32    } - 33} + 32        return $this->getBalance(); + 33    } + 34} diff --git a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_branch.html b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_branch.html index 7d1bf5cc1..11336c19e 100644 --- a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_branch.html +++ b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_branch.html @@ -318,8 +318,9 @@ 29%s 30 31%s - 32%s - 33%s + 32        return $this->getBalance(); + 33    } + 34} @@ -393,23 +394,6 @@
BankAccoun - - - -
- - - - +%a diff --git a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html index d69dfdcae..681005e0e 100644 --- a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html +++ b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html @@ -319,7 +319,8 @@ 30 31%s 32%s - 33%s + 33    } + 34} @@ -386,23 +387,6 @@
BankAccoun - - - -
- - - - +%a