multiple arguments for mocked functions….

Posted: August 17th, 2009 | Author: tolleiv | Tags: , | 1 Comment »

If you look into the PHPUnit documentation ( http://www.phpunit.de/manual/3.3/en/test-doubles.html#test-doubles.mock-objects ) you’ll see some nice examples but non of them shows how to translate a function with multiple arguments into a mock-assumption.

Within the examples you’ll find:
$observer->expects($this->once())->method('update')
->with($this->equalTo('something'));

So what if the “update” function has two arguments, pretty easy:
$observer->expects($this->once())->method('update')
->with($this->equalTo('something'), $this->equalTo('something else'));

I guess Sebastian though that that there’s no need for documentation if something is so obvious :(


One Comment on “multiple arguments for mocked functions….”

  1. 1 Bill Bartmann Scam? said at 5:21 pm on September 8th, 2009:

    I’m so glad I found this site…Keep up the good work