【发布时间】:2016-09-27 07:14:11
【问题描述】:
与此类似的问题:PHPUnit assert no method is called
如何断言除了我可以定义的一些方法之外没有方法被调用?下面的测试没有通过,因为 PHPUnit 验证了所有的 expects()。
//Here assert that only 'firstMethodToBeCalled' and 'secondMethodToBeCalled' are called, and no more
$mock = $this->getMockBuilder('SomeClass')->getMock();
$mock->expects($this->never())
->method($this->anything());
$mock->expects($this->once())
->method('firstMethodToBeCalled');
$mock->expects($this->once())
->method('secondMethodToBeCalled');
【问题讨论】:
-
我已经删除了我的答案,因为他们都没有工作,对此感到抱歉。
标签: php unit-testing phpunit