我相信做到这一点的方法是:
$observer->expects($this->once())
->method('method')
->with($this->equalTo($arg1),$this->equalTo($arg2));
或
$observer->expects($this->once())
->method('method')
->with($arg1, $arg2);
如果需要在 2nd arg 上执行不同类型的断言,也可以执行此操作:
$observer->expects($this->once())
->method('method')
->with($this->equalTo($arg1),$this->stringContains('some_string'));
如果需要确保某些参数传递多个断言,请使用 logicalAnd()
$observer->expects($this->once())
->method('method')
->with($this->logicalAnd($this->stringContains('a'), $this->stringContains('b')));