Dar*_*ren 3 php phpunit mocking
大家好我怎么能在PHPUnit中做到这一点,一个模拟方法返回它传递的参数?
例如:
$redirector->expects( $this->once() )->method('gotoUrl')->will( $this->returnValue($argument) );
Run Code Online (Sandbox Code Playgroud)
根据PHPUnit手册:
$stub->expects($this->any())
->method('doSomething')
->will($this->returnArgument(0));
Run Code Online (Sandbox Code Playgroud)
$redirector->expects($this->once())
->method('gotoUrl')
->will($this->returnCallback(function() {
$args = func_get_args();
return $args[0]; // or w/e
));
Run Code Online (Sandbox Code Playgroud)