Configurable

RemovePhpUnitCompatibilityTraitRector

Remove use Drupal\Tests\PhpUnitCompatibilityTrait; from test classes. Gated to Drupal 12 only — the trait class is deleted from core in #3582118 and the rule must not fire on Drupal 10/11 where the trait still exists.

 class ExampleTest extends \PHPUnit\Framework\TestCase
 {
-    use \Drupal\Tests\PhpUnitCompatibilityTrait;
 }

Configure your rector.php:

<?php

use DrupalRector\Drupal11\Rector\Deprecation\RemovePhpUnitCompatibilityTraitRector;
use DrupalRector\Rector\ValueObject\DrupalIntroducedVersionConfiguration;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withConfiguredRule(RemovePhpUnitCompatibilityTraitRector::class, [
        new DrupalIntroducedVersionConfiguration('12.0.0'),
    ]);