-
-
Notifications
You must be signed in to change notification settings - Fork 739
Closed
rectorphp/rector-phpunit
#493Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | 2.0.16 |
| PHP | 8.3 |
| PHPUnit | 10.5.46 |
| PHPStan | 2.1.16 |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/9330ed38-6292-464c-adf2-4b627bfd01d0
<?php
namespace App {
trait SomeTrait {
}
class OtherStuff {
public static function Inject(): void
{}
}
}
namespace App\Test {
use App\SomeTrait;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\SomeTrait
*/
final class SomeTraitTest extends TestCase
{
/**
* @covers \App\OtherStuff::Inject
*/
public function testYourThinks(): void
{}
}
}<?php
use App\SomeTrait;
use PHPUnit\Framework\TestCase;
- /**
- * @covers \App\SomeTrait
- */
+ #[\PHPUnit\Framework\Attributes\CoversTrait(\App\SomeTrait::class)]
+ #[\PHPUnit\Framework\Attributes\CoversMethod(\App\OtherStuff::class, 'Inject')]
final class SomeTraitTest extends TestCase
{
- /**
- * @covers \App\OtherStuff::Inject
- */
public function testYourThinks(): void
{}
}
}<?php
declare(strict_types=1);
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withSets([
PHPUnitSetList::PHPUNIT_100,
])
;Responsible rules
CoversAnnotationWithValueToAttributeRector
Expected Behavior
In the code we see an example of a test. Covers are converted into anotations.
This was only partially implemented in PHPunit 10. The class CoversMethod was only added in PHPUnit 11.1.0
The class \PHPUnit\Framework\Attributes\CoversMethod does not exist at this point.
The expected behavior would be that in version PHPunt 10 the class CoversMethod is excluded.
Reactions are currently unavailable