badge-poser
badge-poser copied to clipboard
Use a standard for mocking dependencies
As per https://github.com/PUGX/badge-poser/pull/393#issuecomment-706952070
I would suggest to stick, for the moment, with PHPUnit built in library. Two main reasons
- It is still the most used, so we won't prevent any collaboration from contributors that doesn't know about Prophecy
- The trait provided for Prophecy usage into PHPUnit could introduce a regression due to Prophecy version 1.10 (see https://github.com/phpspec/prophecy-phpunit/issues/27)
so your proposal would be to remove Prophecy and use phpunit exclusively?
/cc @garak @AlessandroMinoccheri
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.
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.
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.
ok, so I think that use PHPUnit built-in is the best way at the moment to mock dependencies.
ok guys! Thanks so much for the fruitful discussion! 🚀