【发布时间】:2015-05-13 16:34:09
【问题描述】:
我有一个PHPUnit_Framework_MockObject_MockObject 和一个Logger。
在单元测试中,我不希望使用特定的字符串参数 doNotCallMeWithThisString 调用 warn 方法。
我已经走到这一步了:
public function testThis()
{
...
$logger = $this->getMockLogger();
$logger->expects($this->exactly(0))->method('warn')->with(
$this->equalTo('doNotCallMeWithThisString')
);
...
}
但这失败了,因为exactly(0) 将对warn 方法的任何调用标记为错误,即使字符串参数是somethingEntirelyUnrelated。
我如何告诉模拟对象对warn 的任何调用都可以,除非它是使用特定字符串调用的?
【问题讨论】:
标签: php unit-testing mocking phpunit