我的方法有3个参数,但我只想测试arg3,arg1和arg2无所谓:
$observer = $this->getMock('SomeObserverClass', array('myMethod'));
$observer->expects($this->once())
->method('myMethod')
->with(null, null, $this->equalTo($arg3));
将它们设置为null或!$ this-> empty()不起作用。
方法签名:
public function myMethod(Integer $arg1, String $arg2, String $arg3) {...}
答案 0 :(得分:1)
您可以使用anything
匹配器。尝试:
$observer->expects($this->once())
->method('myMethod')
->with($this->anything(), $this->anything(), $this->equalTo($arg3));