Decorate willReturnMap() calls with expects on the mock object if missing
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
final class SomeTest extends TestCase
{
private MockObject $someMock;
protected function setUp(): void
{
$this->someMock = $this->createMock(SomeClass::class);
- $this->someMock->method("someMethod")
+ $this->someMock->expects($this->exactly(2))
+ ->method("someMethod")
->willReturnMap([
["arg1", "arg2", "result1"],
["arg3", "arg4", "result2"],
]);
}
}
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Expression\DecorateWillReturnMapWithExpectsMockRector;
return RectorConfig::configure()
->withRules([
DecorateWillReturnMapWithExpectsMockRector::class,
]);