大家好我怎么能在PHPUnit中这样做,一个模拟方法返回它传递的参数?
E.g:
$redirector->expects( $this->once() )->method('gotoUrl')->will( $this->returnValue($argument) );
答案 0 :(得分:7)
$stub->expects($this->any())
->method('doSomething')
->will($this->returnArgument(0));
答案 1 :(得分:5)
$redirector->expects($this->once())
->method('gotoUrl')
->will($this->returnCallback(function() {
$args = func_get_args();
return $args[0]; // or w/e
));