Skip to content
Advertisement

PHPUnit: expects method meaning

When I create a new mock I need to call the expects method. What exactly it does? What about its arguments?

JavaScript

I can’t find the reason anywhere (I’ve tried docs). I’ve read the sources but I can’t understand it.

Advertisement

Answer

expects() – Sets how many times you expect a method to be called:

JavaScript

If you know, that method is called once use $this->once() in expects(), otherwise use $this->any()

see:
PHPUnit mock with multiple expects() calls

https://phpunit.de/manual/current/en/test-doubles.html#test-doubles.stubs

http://www.slideshare.net/mjlivelyjr/advanced-phpunit-testing

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement