Hi all how can I make it so in PHPUnit a mocked method returns its passed argument?
E.g:
$redirector->expects( $this->once() )->method('gotoUrl')->will( $this->returnValue($argument) );
根据PHPUnit 手册:
$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
));