Adds #[CoversClass(...)]
attribute to test files guessing source class name.
class SomeService
{
}
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
+#[CoversClass(SomeService::class)]
class SomeServiceFunctionalTest extends TestCase
{
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddCoversClassAttributeRector;
use Rector\PHPUnit\ValueObject\TestClassSuffixesConfig;
return RectorConfig::configure()
->withConfiguredRule(AddCoversClassAttributeRector::class, [
new TestClassSuffixesConfig([
'Test',
'TestCase',
'FunctionalTest',
'IntegrationTest',
]),
]);