1

我的方法有 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) {...}
4

1 回答 1

2

您可以使用anything匹配器。尝试:

$observer->expects($this->once())
     ->method('myMethod')
     ->with($this->anything(), $this->anything(), $this->equalTo($arg3));
于 2013-04-13T10:10:44.753 回答