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

Found 6 rules:

CreateStubInCoalesceArgRector

Use createStub() over createMock() when used as argument/array item coalesce ?? fallback

 use PHPUnit\Framework\TestCase;

 final class SomeTest extends TestCase
 {
     public function test()
     {
         $mockObject = $this->>get('service');
-        $this->someMethod($mockObject ?? $this->createMock(SomeClass::class));
+        $this->someMethod($mockObject ?? $this->createStub(SomeClass::class));
     }

     private function someMethod($someClass)
     {
-    }
 }

CreateStubOverCreateMockArgRector

Use createStub() over createMock() when used as argument or array value and does not add any mock requirements

 use PHPUnit\Framework\TestCase;
+
 final class SomeTest extends TestCase
 {
     public function test()
     {
-        $this->someMethod($this->createMock(SomeClass::class));
+        $this->someMethod($this->createStub(SomeClass::class));
     }

     private function someMethod($someClass)
     {
     }
 }

RemoveOverrideFinalConstructTestCaseRector

Remove override final construct test case

 use PHPUnit\Framework\TestCase;

 final class SomeClass extends TestCase
 {
-    public function __construct()
-    {
-        parent::__construct(static::class);
-    }
 }

PropertyCreateMockToCreateStubRector

Change mock object property that is never mocked to createStub()

 use PHPUnit\Framework\TestCase;

 final class SomeTest extends TestCase
 {
-    private \PHPUnit\Framework\MockObject\MockObject $someServiceMock;
+    private \PHPUnit\Framework\MockObject\Stub\Stub $someServiceMock;

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

     public function testOne(): void
     {
         $someObject = new SomeClass($this->someServiceMock);
     }

     public function testTwo(): void
     {
         $someObject = new AnotherClass($this->someServiceMock);
     }
 }

AssertIsTypeMethodCallRector

Replaces Assert::isType() calls with type-specific Assert::is*() calls

 use PHPUnit\Framework\TestCase;

 final class SomeClass extends TestCase
 {
     public function testMethod(): void
     {
-        $this->assertThat([], $this->isType('array'));
+        $this->assertThat([], $this->isArray());
     }
 }

ExpressionCreateMockToCreateStubRector

Replace createMock() assigned to variable that is only used as arg with no expectations, to createStub()

 use PHPUnit\Framework\TestCase;

 final class SomeTest extends TestCase
 {
     public function test(): void
     {
-        $mock = $this->createMock(SomeClass::class);
+        $mock = $this->createStub(SomeClass::class);

         $someObject = new SomeClass($mock);
         $this->assertSame($mock, $someObject->getDependency());
     }
 }