From 8723a2196fe2714a8dc8d9ac15ae718c42d45a6d Mon Sep 17 00:00:00 2001 From: Bastien Philippe Date: Thu, 1 Oct 2020 10:01:39 +0200 Subject: [PATCH] Fix line and branch rate in Cobertura --- src/Report/Cobertura.php | 8 ++++---- tests/_files/BankAccount-cobertura-line.xml | 2 +- tests/_files/BankAccount-cobertura-path.xml | 2 +- tests/_files/class-with-anonymous-function-cobertura.xml | 2 +- tests/_files/ignored-lines-cobertura.xml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Report/Cobertura.php b/src/Report/Cobertura.php index fa38b64f2..3662a9ecd 100644 --- a/src/Report/Cobertura.php +++ b/src/Report/Cobertura.php @@ -49,13 +49,13 @@ public function process(CodeCoverage $coverage, ?string $target = null, ?string $coverageElement = $document->createElement('coverage'); - $linesValid = $report->numberOfExecutedLines(); - $linesCovered = $report->numberOfExecutableLines(); + $linesValid = $report->numberOfExecutableLines(); + $linesCovered = $report->numberOfExecutedLines(); $lineRate = $linesValid === 0 ? 0 : ($linesCovered / $linesValid); $coverageElement->setAttribute('line-rate', (string) $lineRate); - $branchesValid = $report->numberOfExecutedBranches(); - $branchesCovered = $report->numberOfExecutableBranches(); + $branchesValid = $report->numberOfExecutableBranches(); + $branchesCovered = $report->numberOfExecutedBranches(); $branchRate = $branchesValid === 0 ? 0 : ($branchesCovered / $branchesValid); $coverageElement->setAttribute('branch-rate', (string) $branchRate); diff --git a/tests/_files/BankAccount-cobertura-line.xml b/tests/_files/BankAccount-cobertura-line.xml index 0ca5a6e0e..b1fc283b9 100644 --- a/tests/_files/BankAccount-cobertura-line.xml +++ b/tests/_files/BankAccount-cobertura-line.xml @@ -1,6 +1,6 @@ - + %s diff --git a/tests/_files/BankAccount-cobertura-path.xml b/tests/_files/BankAccount-cobertura-path.xml index c221fd1fd..948eb73c6 100644 --- a/tests/_files/BankAccount-cobertura-path.xml +++ b/tests/_files/BankAccount-cobertura-path.xml @@ -1,6 +1,6 @@ - + %s diff --git a/tests/_files/class-with-anonymous-function-cobertura.xml b/tests/_files/class-with-anonymous-function-cobertura.xml index 23b832314..83451bc2e 100644 --- a/tests/_files/class-with-anonymous-function-cobertura.xml +++ b/tests/_files/class-with-anonymous-function-cobertura.xml @@ -1,6 +1,6 @@ - + %s diff --git a/tests/_files/ignored-lines-cobertura.xml b/tests/_files/ignored-lines-cobertura.xml index 87622f207..e0f9c4c38 100644 --- a/tests/_files/ignored-lines-cobertura.xml +++ b/tests/_files/ignored-lines-cobertura.xml @@ -1,6 +1,6 @@ - + %s