phpspec / prophecy

Highly opinionated mocking framework for PHP 5.3+
MIT License
8.53k stars 241 forks source link

Add method for incrementing a prediction's call times #473

Closed krystalcode closed 3 years ago

krystalcode commented 4 years ago

In some complex test cases with data providers I find the need to be able to increment the count of an existing call times prediciton. For example, I register the prediction, but if some condition passes I want to easily increment the count instead of registering it again. Othewise I'd have to keep track of how many times it should be called and that makes writing the tests more difficult.

I have added a method shouldBeCalledAddTimes($count); if there is an existing call times prediction it will add the given count to the prediction's count, otherwise it will create a new one.

Let me know if that sounds the right approach and I can take this further.

ciaranmcnulty commented 4 years ago

This seems ok I guess; I'm not too clear what the use case is

Can you write some tests?

ciaranmcnulty commented 3 years ago

Closing due to inactivity; please do re-open if you can come up with some tests that clarify what it's about