I don't really understand why setting the expectations when creating the listeners is necessary.
Theoretically: When I create a listener on an object, lets say: listenTo('foo'), snaptest could listen to all calls to foo.
If I then call:
$mock->foo();
$mock->foo(5);
$mock->foo(5, 'test');
the assertCallCount for foo, without expectation could be 3, with the expectation 5 it would be 2, and with 5 & 'test' only 1.
Asserting the call counts could just work the same.
I understand what the expectations in the listeners do now... I'm just what the benefit of it ist.
cheers, and thanks for the reply
Matthias Loitsch
m...@tthias.com
What I still can't really figure out, is why Snaptest doesn't simply use overloading to log *all* calls to the object.
http://www.php.net/manual/en/language.oop5.overloading.php
Why do you need to create a signature of the method & parameters in advance?
The mock object could just be a generic object, that catches all method calls, and attribute accesses, and checks if the class it should inherit from »supports« them. It could then go through the stored setReturnValue() calls, and see if it has to return something specific or not, and simply log the call, so you can ask later if it has been called...
Or am I missing something?
Thanks,
Matthias Loitsch
m...@tthias.com
The other use case (seldom used, but sometimes required) is a partial
mock. You want the object to behave exactly like the original, only
with one or two methods altered.
Hope this helps.
Jakob