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

Use createStub whenever possible #6043

Closed
wants to merge 2 commits into from

Conversation

greg0ire
Copy link
Contributor

Just wanted to try the rector class I failed to contribute: rectorphp/rector#3042


$datagrid = $this->createMock(DatagridInterface::class);
$datagrid = $this->createStub(DatagridInterface::class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following line calls expects(). Isn't that the case where the test double should be considered as a mock according the issue referenced in the Rector (sebastianbergmann/phpunit#3120 (comment))?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 well spotted… guess the rule does not work properly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the tests are not failing when you expect something on a Stub, I don't really see the benefit of using it. Using both seems just confusing to me.

But that's a Phpunit debate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests that should fail are static analysis tests, and we don't have those for now, so indeed, let's maybe not merge this until we do.

Using both seems just confusing to me.

I think the main goal is precisely to clear the confusion between a stub and a mock, which serve different purposes as outlined in the linked issue above. It's never been super clear to me, but I think if I start using different words, I will start noticing patterns and use them when appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reported the bug here: rectorphp/rector#3157

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants