Find a Rector rule
Find the best Rector rule to solve your problem. Searching through 1108 rules.
Found 4 rules, grouped by set: Clear
phpunit/phpunit 12
4 matches
AllowMockObjectsForDataProviderRector
phpunit/phpunit >=12.5.2
Add #[AllowMockObjectsWithoutExpectations] attribute to PHPUnit test classes that have methods with data providers and mock objects without expectations
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
+#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
final class SomeClass extends TestCase
{
#[DataProvider('someDataProvider')]
public function test()
{
$someMock = $this->createMock(\stdClass::class);
$someMock->expects('method')->willReturn(true);
}
public static function someDataProvider(): iterable
{
yield [1];
yield [2];
yield [3];
}
}
AllowMockObjectsWhereParentClassRector
phpunit/phpunit >=12.5.2
Add #[AllowMockObjectsWithoutExpectations] attribute to PHPUnit test classes with a 3rd party test case, that provides any mocks
use Symfony\Component\Form\Test\TypeTestCase;
+#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
final class SomeTest extends TypeTestCase
{
}
AnyMatcherToNewAnyInvokedCountRector
phpunit/phpunit >=12.5
Change deprecated $this->any() matcher assign to direct new AnyInvokedCount()
+use PHPUnit\Framework\MockObject\Rule\AnyInvokedCount;
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
public function test(): void
{
- $matcher = $this->any();
+ $matcher = new AnyInvokedCount();
}
}
RemoveOverrideFinalConstructTestCaseRector
phpunit/phpunit >=12.0.3
Remove override final construct test case
use PHPUnit\Framework\TestCase;
final class SomeClass extends TestCase
{
- public function __construct()
- {
- parent::__construct(static::class);
- }
}