Skip to content

Commit

Permalink
Remove the processUncoveredFiles attribute on the <coverage> XML conf…
Browse files Browse the repository at this point in the history
…iguration element (because the corresponding functionality in php-code-coverage has been removed)
  • Loading branch information
sebastianbergmann committed May 4, 2021
1 parent 4b70280 commit 602370c
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 34 deletions.
3 changes: 2 additions & 1 deletion ChangeLog-10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ All notable changes of the PHPUnit 10.0 release series are documented in this fi
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): Deprecate assertions that operate on class/object properties
* Removed the `PHPUnit\Runner\TestSuiteLoader` interface
* Removed the `<listeners>` XML configuration element and its children
* Removed the `groups` attribute on the `test` element in the TestDox XML report
* Removed the `groups` attribute on the `<test>` element in the TestDox XML report
* Removed the `processUncoveredFiles` attribute on the `<coverage>` XML configuration element

[10.0.0]: https://github.com/sebastianbergmann/phpunit/compare/9.5...master
3 changes: 1 addition & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true"
ignoreDeprecatedCodeUnits="true">
<coverage ignoreDeprecatedCodeUnits="true">
<include>
<directory suffix=".php">src</directory>
</include>
Expand Down
1 change: 0 additions & 1 deletion phpunit.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
<xs:attribute name="cacheDirectory" type="xs:anyURI"/>
<xs:attribute name="pathCoverage" type="xs:boolean" default="false"/>
<xs:attribute name="includeUncoveredFiles" type="xs:boolean" default="true"/>
<xs:attribute name="processUncoveredFiles" type="xs:boolean" default="false"/>
<xs:attribute name="ignoreDeprecatedCodeUnits" type="xs:boolean" default="false"/>
<xs:attribute name="disableCodeCoverageIgnore" type="xs:boolean" default="false"/>
</xs:complexType>
Expand Down
6 changes: 0 additions & 6 deletions src/TextUI/TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,6 @@ public function run(TestSuite $suite, array $arguments = [], array $warnings = [
} else {
CodeCoverage::instance()->excludeUncoveredFiles();
}

if ($codeCoverageConfiguration->processUncoveredFiles()) {
CodeCoverage::instance()->processUncoveredFiles();
} else {
CodeCoverage::instance()->doNotProcessUncoveredFiles();
}
}
}

Expand Down
10 changes: 1 addition & 9 deletions src/TextUI/XmlConfiguration/CodeCoverage/CodeCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ final class CodeCoverage

private bool $includeUncoveredFiles;

private bool $processUncoveredFiles;

private bool $ignoreDeprecatedCodeUnits;

private bool $disableCodeCoverageIgnore;
Expand All @@ -62,7 +60,7 @@ final class CodeCoverage

private ?Xml $xml = null;

public function __construct(?Directory $cacheDirectory, DirectoryCollection $directories, FileCollection $files, DirectoryCollection $excludeDirectories, FileCollection $excludeFiles, bool $pathCoverage, bool $includeUncoveredFiles, bool $processUncoveredFiles, bool $ignoreDeprecatedCodeUnits, bool $disableCodeCoverageIgnore, ?Clover $clover, ?Cobertura $cobertura, ?Crap4j $crap4j, ?Html $html, ?Php $php, ?Text $text, ?Xml $xml)
public function __construct(?Directory $cacheDirectory, DirectoryCollection $directories, FileCollection $files, DirectoryCollection $excludeDirectories, FileCollection $excludeFiles, bool $pathCoverage, bool $includeUncoveredFiles, bool $ignoreDeprecatedCodeUnits, bool $disableCodeCoverageIgnore, ?Clover $clover, ?Cobertura $cobertura, ?Crap4j $crap4j, ?Html $html, ?Php $php, ?Text $text, ?Xml $xml)
{
$this->cacheDirectory = $cacheDirectory;
$this->directories = $directories;
Expand All @@ -71,7 +69,6 @@ public function __construct(?Directory $cacheDirectory, DirectoryCollection $dir
$this->excludeFiles = $excludeFiles;
$this->pathCoverage = $pathCoverage;
$this->includeUncoveredFiles = $includeUncoveredFiles;
$this->processUncoveredFiles = $processUncoveredFiles;
$this->ignoreDeprecatedCodeUnits = $ignoreDeprecatedCodeUnits;
$this->disableCodeCoverageIgnore = $disableCodeCoverageIgnore;
$this->clover = $clover;
Expand Down Expand Up @@ -154,11 +151,6 @@ public function disableCodeCoverageIgnore(): bool
return $this->disableCodeCoverageIgnore;
}

public function processUncoveredFiles(): bool
{
return $this->processUncoveredFiles;
}

/**
* @psalm-assert-if-true !null $this->clover
*/
Expand Down
2 changes: 1 addition & 1 deletion src/TextUI/XmlConfiguration/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class Generator
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<coverage>
<include>
<directory suffix=".php">{src_directory}</directory>
</include>
Expand Down
8 changes: 0 additions & 8 deletions src/TextUI/XmlConfiguration/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ private function codeCoverage(string $filename, DOMXPath $xpath, DOMDocument $do
$cacheDirectory = null;
$pathCoverage = false;
$includeUncoveredFiles = true;
$processUncoveredFiles = false;
$ignoreDeprecatedCodeUnits = false;
$disableCodeCoverageIgnore = false;

Expand All @@ -333,12 +332,6 @@ private function codeCoverage(string $filename, DOMXPath $xpath, DOMDocument $do
true
);

$processUncoveredFiles = $this->getBooleanAttribute(
$element,
'processUncoveredFiles',
false
);

$ignoreDeprecatedCodeUnits = $this->getBooleanAttribute(
$element,
'ignoreDeprecatedCodeUnits',
Expand Down Expand Up @@ -463,7 +456,6 @@ private function codeCoverage(string $filename, DOMXPath $xpath, DOMDocument $do
$this->readFilterFiles($filename, $xpath, 'coverage/exclude/file'),
$pathCoverage,
$includeUncoveredFiles,
$processUncoveredFiles,
$ignoreDeprecatedCodeUnits,
$disableCodeCoverageIgnore,
$clover,
Expand Down
1 change: 1 addition & 0 deletions src/TextUI/XmlConfiguration/Migration/MigrationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ final class MigrationBuilder
RemoveTestSuiteLoaderAttributes::class,
RemoveCacheResultFileAttribute::class,
RemoveCoverageElementCacheDirectoryAttribute::class,
RemoveCoverageElementProcessUncoveredFilesAttribute::class,
IntroduceCacheDirectoryAttribute::class,
RenameBackupStaticAttributesAttribute::class,
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TextUI\XmlConfiguration;

use DOMDocument;
use DOMElement;

/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class RemoveCoverageElementProcessUncoveredFilesAttribute implements Migration
{
public function migrate(DOMDocument $document): void
{
$node = $document->getElementsByTagName('coverage')->item(0);

if (!$node instanceof DOMElement || $node->parentNode === null) {
return;
}

if ($node->hasAttribute('processUncoveredFiles')) {
$node->removeAttribute('processUncoveredFiles');
}
}
}
1 change: 0 additions & 1 deletion tests/_files/XmlConfigurationMigration/output-9.2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
cacheDirectory=".phpunit.cache">

<coverage includeUncoveredFiles="true"
processUncoveredFiles="true"
ignoreDeprecatedCodeUnits="true"
disableCodeCoverageIgnore="true">
<include>
Expand Down
2 changes: 1 addition & 1 deletion tests/_files/XmlConfigurationMigration/output-9.5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
cacheDirectory=".phpunit.cache">

<coverage processUncoveredFiles="true">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/force-covers-annotation/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/risky-tests/global-state/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/TextUI/XmlConfigurationGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testGeneratesConfigurationCorrectly(): void
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
Expand Down
1 change: 0 additions & 1 deletion tests/unit/TextUI/XmlConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ public function testCodeCoverageConfigurationIsReadCorrectly(): void

$this->assertTrue($codeCoverage->pathCoverage());
$this->assertTrue($codeCoverage->includeUncoveredFiles());
$this->assertTrue($codeCoverage->processUncoveredFiles());
$this->assertTrue($codeCoverage->ignoreDeprecatedCodeUnits());
$this->assertTrue($codeCoverage->disableCodeCoverageIgnore());

Expand Down

0 comments on commit 602370c

Please sign in to comment.