Remove never used property mock, only to set expectations
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
- private $mockProperty = null;
-
protected function setUp(): void
{
- $this->mockProperty = $this->createMock(SomeClass::class);
-
- $this->mockProperty->expects($this->once())
- ->method('someMethod')
- ->willReturn('someValue');
}
}
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Class_\RemoveNeverUsedMockPropertyRector;
return RectorConfig::configure()
->withRules([
RemoveNeverUsedMockPropertyRector::class,
]);