【发布时间】:2011-07-25 23:17:58
【问题描述】:
可以这样配置PHPUnit mock吗?
$context = $this->getMockBuilder('Context')
->getMock();
$context->expects($this->any())
->method('offsetGet')
->with('Matcher')
->will($this->returnValue(new Matcher()));
$context->expects($this->any())
->method('offsetGet')
->with('Logger')
->will($this->returnValue(new Logger()));
我使用 PHPUnit 3.5.10,当我请求 Matcher 时它失败了,因为它需要“Logger”参数。 就像第二个期望是重写第一个,但是当我转储模拟时,一切看起来都很好。
【问题讨论】: