rectorphp / swiss-knife

Swiss knife in pocket of every upgrade architect!
https://getrector.com
MIT License
72 stars 8 forks source link

Detect getMockBuilder #38

Closed ruudk closed 3 weeks ago

ruudk commented 3 weeks ago

It should also detect PHPUnit's \PHPUnit\Framework\TestCase::getMockBuilder.

TomasVotruba commented 3 weeks ago

How does PHPUnit code with this method look like? Just to verify.

Have you tested it locally?

ruudk commented 3 weeks ago
$mock = $this->getMockBuilder(FetchMethod::class)
            ->disableOriginalConstructor()
            ->onlyMethods($methods)
            ->getMock();

So that works the same as:

$mock =  $this->createMock(EventRecorder::class);

I did not test it, but I feel this is the same thing.

ruudk commented 3 weeks ago

I think we should also do the same for createStub. But I don't use that myself.

TomasVotruba commented 3 weeks ago

Could you test it locally, please? Otherwise we'll have to add testing suite to make sure these are picked up correctly. Which we might have as well :)

ruudk commented 3 weeks ago

Ok, I just tested it and it does work perfectly!