【发布时间】:2013-05-02 00:39:01
【问题描述】:
大家好,我怎样才能在 PHPUnit 中使模拟方法返回其传递的参数?
例如:
$redirector->expects( $this->once() )->method('gotoUrl')->will( $this->returnValue($argument) );
【问题讨论】:
大家好,我怎样才能在 PHPUnit 中使模拟方法返回其传递的参数?
例如:
$redirector->expects( $this->once() )->method('gotoUrl')->will( $this->returnValue($argument) );
【问题讨论】:
$stub->expects($this->any())
->method('doSomething')
->will($this->returnArgument(0));
【讨论】:
$redirector->expects($this->once())
->method('gotoUrl')
->will($this->returnCallback(function() {
$args = func_get_args();
return $args[0]; // or w/e
));
【讨论】: