Php 如何返回模拟方法的参数?
嗨,大家好,在PHPUnit中,我怎样才能使它如此呢?模拟方法返回其传递的参数 例如: 根据:Php 如何返回模拟方法的参数?,php,mocking,phpunit,Php,Mocking,Phpunit,嗨,大家好,在PHPUnit中,我怎样才能使它如此呢?模拟方法返回其传递的参数 例如: 根据: 谢谢,这就成功了,很酷,它是在一个结束。我已经找到了这样的嘲笑解决方案。效验如神谢谢谢谢,优化了很多。 $redirector->expects( $this->once() )->method('gotoUrl')->will( $this->returnValue($argument) ); $redirector->expects($this->onc
谢谢,这就成功了,很酷,它是在一个结束。我已经找到了这样的嘲笑解决方案。效验如神谢谢谢谢,优化了很多。
$redirector->expects( $this->once() )->method('gotoUrl')->will( $this->returnValue($argument) );
$redirector->expects($this->once())
->method('gotoUrl')
->will($this->returnCallback(function() {
$args = func_get_args();
return $args[0]; // or w/e
));
$stub->expects($this->any())
->method('doSomething')
->will($this->returnArgument(0));