How to return the argument of a mocked method?

mocking, php, phpunit

Solution

As per the PHPUnit manual:

$stub->expects($this->any())
     ->method('doSomething')
     ->will($this->returnArgument(0));

Problem

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) ); ```

Original source