Find the best Rector rule to solve your problem. Searching through 1011 rules.

Found 5 rules:

AllowMockObjectsForDataProviderRector

Add #[AllowMockObjectsWithoutExpectations] attribute to PHPUnit test classes that have methods with data providers and mock objects without expectations

 use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;

+#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
 final class SomeClass extends TestCase
 {
     #[DataProvider('someDataProvider')]
     public function test()
     {
         $someMock = $this->createMock(\stdClass::class);
         $someMock->expects('method')->willReturn(true);
     }

     public static function someDataProvider(): iterable
     {
         yield [1];
         yield [2];
         yield [3];
     }
 }
PACKAGE:  phpunit/phpunit >=12.5.2

AllowMockObjectsWhereParentClassRector

Add #[AllowMockObjectsWithoutExpectations] attribute to PHPUnit test classes with a 3rd party test case, that provides any mocks

 use Symfony\Component\Form\Test\TypeTestCase;

+#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
 final class SomeTest extends TypeTestCase
 {
 }
PACKAGE:  phpunit/phpunit >=12.5.2

AllowMockObjectsWithoutExpectationsAttributeRector

Add #[AllowMockObjectsWithoutExpectations] attribute to PHPUnit test classes with mock properties used in multiple methods but one, to avoid irrelevant notices in tests run

 use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
+
+#[AllowMockObjectsWithoutExpectations]
 final class SomeTest extends TestCase
 {
     private \PHPUnit\Framework\MockObject\MockObject $someServiceMock;

     protected function setUp(): void
     {
         $this->someServiceMock = $this->createMock(SomeService::class);
     }

     public function testOne(): void
     {
-        // use $this->someServiceMock
+        $this->someServiceMock->expects($this->once())
+            ->method('someMethod')
+            ->willReturn('someValue');
     }

     public function testTwo(): void
     {
-        // use $this->someServiceMock
+        $this->someServiceMock->expects($this->once())
+            ->method('someMethod')
+            ->willReturn('anotherValue');
     }
 }
PACKAGE:  phpunit/phpunit >=12.5.2

AnyMatcherToNewAnyInvokedCountRector

Change deprecated $this->any() matcher assign to direct new AnyInvokedCount()

+use PHPUnit\Framework\MockObject\Rule\AnyInvokedCount;
 use PHPUnit\Framework\TestCase;

 final class SomeTest extends TestCase
 {
     public function test(): void
     {
-        $matcher = $this->any();
+        $matcher = new AnyInvokedCount();
     }
 }
PACKAGE:  phpunit/phpunit >=12.5

RemoveOverrideFinalConstructTestCaseRector

Remove override final construct test case

 use PHPUnit\Framework\TestCase;

 final class SomeClass extends TestCase
 {
-    public function __construct()
-    {
-        parent::__construct(static::class);
-    }
 }
PACKAGE:  phpunit/phpunit >=12.0.3