Skip to content

[CodeQuality] Skip TestCase suffix classes in RemoveNeverUsedMockPropertyRector#709

Merged
TomasVotruba merged 2 commits into
mainfrom
remove-mock-skip-testcase
Jul 11, 2026
Merged

[CodeQuality] Skip TestCase suffix classes in RemoveNeverUsedMockPropertyRector#709
TomasVotruba merged 2 commits into
mainfrom
remove-mock-skip-testcase

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Abstract *TestCase classes are most likely extended, with mock properties used in child test classes. This rule was removing those still-used mocks. Now skips any class whose name ends with TestCase.

-abstract class SomeAbstractTestCase extends TestCase
-{
-    private MockObject $mockProperty;
-
-    protected function setUp(): void
-    {
-        $this->mockProperty = $this->createMock(\stdClass::class);
-        $this->mockProperty->expects($this->once())
-            ->method('someMethod')
-            ->willReturn('someValue');
-    }
-}

Above class is now left untouched (skip_test_case_suffix.php.inc fixture).

…ertyRector

Abstract *TestCase classes are most likely extended, with mock properties used in child classes. Skip them to avoid removing still-used mocks.
@TomasVotruba TomasVotruba merged commit b9985d8 into main Jul 11, 2026
8 checks passed
@TomasVotruba TomasVotruba deleted the remove-mock-skip-testcase branch July 11, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant