Skip to content

Commit

Permalink
Merge branch '9.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Sep 10, 2022
2 parents 93784f8 + 5047288 commit 37e2852
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 10 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.md
Expand Up @@ -19,6 +19,12 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* This component is no longer supported on PHP 7.3, PHP 7.4 and PHP 8.0
* This component no longer supports Xdebug 2

## [9.2.18] - 2022-MM-DD

### Fixed

* [#935](https://github.com/sebastianbergmann/php-code-coverage/pull/935): Cobertura package name attribute is always empty

## [9.2.17] - 2022-08-30

### Changed
Expand Down Expand Up @@ -433,6 +439,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* This component is no longer supported on PHP 7.1

[10.0.0]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2...master
[9.2.18]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.17...9.2
[9.2.17]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.16...9.2.17
[9.2.16]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.15...9.2.16
[9.2.15]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.14...9.2.15
Expand Down
5 changes: 2 additions & 3 deletions src/Report/Cobertura.php
Expand Up @@ -25,7 +25,7 @@ final class Cobertura
/**
* @throws WriteOperationFailedException
*/
public function process(CodeCoverage $coverage, ?string $target = null, ?string $name = null): string
public function process(CodeCoverage $coverage, ?string $target = null): string
{
$time = (string) time();

Expand Down Expand Up @@ -84,9 +84,8 @@ public function process(CodeCoverage $coverage, ?string $target = null, ?string

$packageElement = $document->createElement('package');
$packageComplexity = 0;
$packageName = $name ?? '';

$packageElement->setAttribute('name', $packageName);
$packageElement->setAttribute('name', str_replace($report->pathAsString() . DIRECTORY_SEPARATOR, '', $item->pathAsString()));

$linesValid = $item->numberOfExecutableLines();
$linesCovered = $item->numberOfExecutedLines();
Expand Down
2 changes: 1 addition & 1 deletion tests/_files/BankAccount-cobertura-line.xml
Expand Up @@ -5,7 +5,7 @@
<source>%s</source>
</sources>
<packages>
<package name="BankAccount" line-rate="0.55555555555556" branch-rate="0" complexity="5">
<package name="BankAccount.php" line-rate="0.55555555555556" branch-rate="0" complexity="5">
<classes>
<class name="BankAccount" filename="BankAccount.php" line-rate="0.55555555555556" branch-rate="0" complexity="5">
<methods>
Expand Down
2 changes: 1 addition & 1 deletion tests/_files/BankAccount-cobertura-path.xml
Expand Up @@ -5,7 +5,7 @@
<source>%s</source>
</sources>
<packages>
<package name="BankAccount" line-rate="0.55555555555556" branch-rate="0.42857142857143" complexity="5">
<package name="BankAccount.php" line-rate="0.55555555555556" branch-rate="0.42857142857143" complexity="5">
<classes>
<class name="BankAccount" filename="BankAccount.php" line-rate="0.55555555555556" branch-rate="0.42857142857143" complexity="5">
<methods>
Expand Down
2 changes: 1 addition & 1 deletion tests/_files/class-with-anonymous-function-cobertura.xml
Expand Up @@ -5,7 +5,7 @@
<source>%s</source>
</sources>
<packages>
<package name="" line-rate="1" branch-rate="0" complexity="1">
<package name="source_with_class_and_anonymous_function.php" line-rate="1" branch-rate="0" complexity="1">
<classes>
<class name="CoveredClassWithAnonymousFunctionInStaticMethod" filename="source_with_class_and_anonymous_function.php" line-rate="1" branch-rate="0" complexity="1">
<methods>
Expand Down
2 changes: 1 addition & 1 deletion tests/_files/class-with-outside-function-cobertura.xml
Expand Up @@ -5,7 +5,7 @@
<source>%s</source>
</sources>
<packages>
<package name="" line-rate="0.75" branch-rate="0" complexity="3">
<package name="source_with_class_and_outside_function.php" line-rate="0.75" branch-rate="0" complexity="3">
<classes>
<class name="ClassInFileWithOutsideFunction" filename="source_with_class_and_outside_function.php" line-rate="1" branch-rate="0" complexity="1">
<methods>
Expand Down
2 changes: 1 addition & 1 deletion tests/_files/ignored-lines-cobertura.xml
Expand Up @@ -5,7 +5,7 @@
<source>%s</source>
</sources>
<packages>
<package name="" line-rate="1" branch-rate="0" complexity="2">
<package name="source_with_ignore.php" line-rate="1" branch-rate="0" complexity="2">
<classes>
<class name="Foo" filename="source_with_ignore.php" line-rate="0" branch-rate="0" complexity="1">
<methods/>
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/Report/CoberturaTest.php
Expand Up @@ -21,7 +21,7 @@ public function testLineCoverageForBankAccountTest(): void

$this->assertStringMatchesFormatFile(
TEST_FILES_PATH . 'BankAccount-cobertura-line.xml',
$cobertura->process($this->getLineCoverageForBankAccount(), null, 'BankAccount')
$cobertura->process($this->getLineCoverageForBankAccount(), null)
);
}

Expand All @@ -31,7 +31,7 @@ public function testPathCoverageForBankAccountTest(): void

$this->assertStringMatchesFormatFile(
TEST_FILES_PATH . 'BankAccount-cobertura-path.xml',
$cobertura->process($this->getPathCoverageForBankAccount(), null, 'BankAccount')
$cobertura->process($this->getPathCoverageForBankAccount(), null)
);
}

Expand Down

0 comments on commit 37e2852

Please sign in to comment.