1

I have a some collaborator and I want a method to be called on this collaborator.

Since in implemented method, collaborator is in for loop, phpspec gives me a No calls have been made that match error. If I place the code outside of the loop, the error is gone. Though I need the method to be called inside the loop.

Why it does not work within loop?

DonCallisto
  • 29,419
  • 9
  • 72
  • 100
Lord Zed
  • 750
  • 7
  • 28
  • 1
    My first guess would be that either your loop is empty, or the method is called with different arguments than you expect. Maybe the arguments are different for each run of the loop. Make sure you check these things. – Bartosz Zasada Jan 12 '17 at 08:47
  • empty as in implementation, or in phpspec test as I might not returning some data that goes into loop? – Lord Zed Jan 12 '17 at 08:55
  • I used the wrong word. I meant it as in it runs 0 times. Like in `for (;false;) { doSomething(); }`, `doSomething()` would be called 0 times. – Bartosz Zasada Jan 12 '17 at 10:41
  • post your SUS (system under spec; in other words, your class) and your Spec file, please. – DonCallisto Jan 12 '17 at 18:20
  • Is this question related -> http://stackoverflow.com/questions/41600397/phpspec-no-calls-have-been-made-that-match ? – DonCallisto Jan 12 '17 at 18:20

0 Answers0