August 17, 2009

multiple arguments for mocked functions....

If you look into the PHPUnit documentation ( ) 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 :(

© tolleiv 2016 - CC BY-SA 3.0 - Powered by Hugo