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());
}
}
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\PHPUnit120\Rector\ClassMethod\ExpressionCreateMockToCreateStubRector;
return RectorConfig::configure()
->withRules([
ExpressionCreateMockToCreateStubRector::class,
]);