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 a standard for mocking dependencies #395

Open
DonCallisto opened this issue Oct 12, 2020 · 6 comments
Open

Use a standard for mocking dependencies #395

DonCallisto opened this issue Oct 12, 2020 · 6 comments

Comments

@DonCallisto
Copy link
Collaborator

DonCallisto commented Oct 12, 2020

As per #393 (comment)

I would suggest to stick, for the moment, with PHPUnit built in library.
Two main reasons

  1. It is still the most used, so we won't prevent any collaboration from contributors that doesn't know about Prophecy
  2. The trait provided for Prophecy usage into PHPUnit could introduce a regression due to Prophecy version 1.10 (see Mocks do not fail immedately on unexpected calls phpspec/prophecy-phpunit#27)
@JellyBellyDev
Copy link
Member

so your proposal would be to remove Prophecy and use phpunit exclusively?

/cc @garak @AlessandroMinoccheri

@DonCallisto
Copy link
Collaborator Author

Removing it is not possible. Just don't use Prophecy for the reasons I've stated before.
If you take a look to linked issue, you'll notice that Prophecy won't let tests fail immediatly when an unexpected call is made upon a test double (since 1.10).
I think is better to stick with PHPUnit built-in system for the moment in order to avoid mistakes from new comers.

@AlessandroMinoccheri
Copy link
Member

It could be a solution to use PHPUnit built-in instead of Prophecy.
In my opinion, it's not clear if they will fix the bug immediately.
To change from PHPUnit built-in to Prophecy and vice versa isn't a big problem but we have to understand when the bug is solved which is the best implementation for us.

@DonCallisto
Copy link
Collaborator Author

In my opinion, it's not clear if they will fix the bug immediately.

AFAIK that's not a bug in Prophecy but the desired behaviour. As a matter of fact, PHPSpec - wich uses only Prophecy as mocking library - is not affected because I suspect, internally it handles checks on double's method invokation differently.

The issue is in the trait and how PHPUnit handle (or, in this case, don't) these scenarios.

@AlessandroMinoccheri
Copy link
Member

ok, so I think that use PHPUnit built-in is the best way at the moment to mock dependencies.

@JellyBellyDev
Copy link
Member

ok guys! Thanks so much for the fruitful discussion! 🚀

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

No branches or pull requests

3 participants