-
-
Notifications
You must be signed in to change notification settings - Fork 735
Closed
rectorphp/rector-phpunit
#497Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | 2.0.16 |
Upgrading to PHPUnit v12, I expected rector to handle conversion of some method calls from self / static to $this but not all conversions occurred. See Related MR
Minimal PHP Code Causing Issue
https://getrector.com/demo/b92dacdc-c967-4b3f-b53f-1daef8f6f772
<?php
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
public function test()
{
self::any();
self::never();
self::atLeast();
self::atLeastOnce();
self::once();
self::exactly();
self::atMost();
self::throwException();
self::getActualOutputForAssertion();
self::expectOutputRegex();
self::expectOutputString();
self::expectException();
self::expectExceptionCode();
self::expectExceptionMessage();
self::expectExceptionMessageMatches();
self::expectExceptionObject();
self::expectNotToPerformAssertions();
self::getMockBuilder();
}
}<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitSelfCallRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
return RectorConfig::configure()
->withRules([
PreferPHPUnitThisCallRector::class,
PreferPHPUnitSelfCallRector::class,
]);Expected Behaviour
public function test()
{
- self::any();
- self::never();
- self::atLeast();
- self::atLeastOnce();
- self::once();
- self::exactly();
- self::atMost();
- self::throwException();
- self::getActualOutputForAssertion();
- self::expectOutputRegex();
- self::expectOutputString();
- self::expectException();
- self::expectExceptionCode();
- self::expectExceptionMessage();
- self::expectExceptionMessageMatches();
- self::expectExceptionObject();
- self::expectNotToPerformAssertions();
- self::getMockBuilder();
+ $this->any();
+ $this->never();
+ $this->atLeast();
+ $this->atLeastOnce();
+ $this->once();
+ $this->exactly();
+ $this->atMost();
+ $this->throwException();
+ $this->getActualOutputForAssertion();
+ $this->expectOutputRegex();
+ $this->expectOutputString();
+ $this->expectException();
+ $this->expectExceptionCode();
+ $this->expectExceptionMessage();
+ $this->expectExceptionMessageMatches();
+ $this->expectExceptionObject();
+ $this->expectNotToPerformAssertions();
+ $this->getMockBuilder();
}Actual Behaviour
public function test()
{
self::any();
- self::never();
- self::atLeast();
- self::atLeastOnce();
- self::once();
+ $this->never();
+ $this->atLeast();
+ $this->atLeastOnce();
+ $this->once();
self::exactly();
self::atMost();
self::throwException();
self::getActualOutputForAssertion();
self::expectOutputRegex();
self::expectOutputString();
- self::expectException();
- self::expectExceptionCode();
- self::expectExceptionMessage();
- self::expectExceptionMessageMatches();
+ $this->expectException();
+ $this->expectExceptionCode();
+ $this->expectExceptionMessage();
+ $this->expectExceptionMessageMatches();
self::expectExceptionObject();
self::expectNotToPerformAssertions();
self::getMockBuilder();
}