Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CodeQuality] Add CreateMockToDirectNewRector #402

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Nov 6, 2024

Instead of weak mocking setup, use object directly with type control and IDE support 🎉

-$articleMock = $this->createMock(Article::class);
-$articleMock->method('getName')->willReturn('How stand up against mocking');
+$article = new Article();
+$article->setName('How stand up against mocking');

This rule is applied on Doctrine ORM + ODM entitites only, to have migration under control.

@TomasVotruba TomasVotruba merged commit 29536ff into main Nov 6, 2024
6 checks passed
@TomasVotruba TomasVotruba deleted the tv-add-mock-to-object branch November 6, 2024 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant