Skip to content

Commit

Permalink
Closes #5961
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Oct 7, 2024
1 parent 8367f93 commit f460b5c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 105 deletions.
1 change: 1 addition & 0 deletions ChangeLog-12.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ All notable changes of the PHPUnit 12.0 release series are documented in this fi
* [#5710](https://github.com/sebastianbergmann/phpunit/issues/5710): Support for using comma-separated values with the `--group`, `--exclude-group`, `--covers`, `--uses`, and `--test-suffix` CLI options
* [#5801](https://github.com/sebastianbergmann/phpunit/issues/5801): Support for targeting traits with `#[CoversClass]` and `#[UsesClass]` attributes
* [#5952](https://github.com/sebastianbergmann/phpunit/issues/5952): `includeUncoveredFiles` configuration option
* [#5961](https://github.com/sebastianbergmann/phpunit/issues/5961): Support for targeting trait methods with the `#[CoversMethod]` and `#[UsesMethod]` attributes
* [#5978](https://github.com/sebastianbergmann/phpunit/issues/5978): Support for PHP 8.2

[12.0.0]: https://github.com/sebastianbergmann/phpunit/compare/11.5...main
1 change: 0 additions & 1 deletion DEPRECATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ This functionality is currently [hard-deprecated](https://phpunit.de/backward-co
|-------------------------------------------------------------------|-------------------------------------------------------------|--------|-----------------------------------------------------------------------------------------|
| [#4505](https://github.com/sebastianbergmann/phpunit/issues/4505) | Metadata in doc-comments | 10.3.0 | Metadata in attributes |
| [#5958](https://github.com/sebastianbergmann/phpunit/issues/5958) | `#[CoversTrait]` and `#[UsesTrait]` attributes | 11.4.0 | `#[CoversClass]` and `#[UsesClass]` also target the traits used by the targeted classes |
| [#5960](https://github.com/sebastianbergmann/phpunit/issues/5960) | Targeting traits with `#[CoversMethod]` and `#[UsesMethod]` | 11.4.0 | |
16 changes: 4 additions & 12 deletions src/Metadata/Api/CodeCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,11 @@ private function names(CoversClass|CoversFunction|CoversMethod|CoversTrait|UsesC
);
}

if ($metadata->isCoversMethod() && trait_exists($metadata->className())) {
EventFacade::emitter()->testRunnerTriggeredDeprecation(
sprintf(
'Targeting a trait such as %s with #[CoversMethod] is deprecated.',
$metadata->className(),
),
);
}

if ($metadata->isUsesMethod() && trait_exists($metadata->className())) {
EventFacade::emitter()->testRunnerTriggeredDeprecation(
if (($metadata->isCoversMethod() || $metadata->isUsesMethod()) &&
trait_exists($metadata->className())) {
throw new InvalidCoversTargetException(
sprintf(
'Targeting a trait such as %s with #[UsesMethod] is deprecated.',
'Trait %s is not a valid target for code coverage',
$metadata->className(),
),
);
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit f460b5c

Please sign in to comment.