public function __call($method, $args)
{
if ( ! in_array($method, $this->validMethods))
{
throw new \BadMethodCallException("Not a valid method: {$method}");
}
}
如何测试__call
方法以确保$method
在我的有效方法列表中?现在这就是我所做的;
/**
* @covers World\Transmission::__call()
* @expectedException BadMethodCallException
* @expectedExceptionMessage Not a valid method: foo
*/
public function test__callInvalidRequest()
{
$m = m::mock('World\\Transmission', array($this->config))->makePartial();
$m->foo(array('foo'));
}
我得到的错误是call_user_func_array()
。
Maximum function nesting level of '100' reached, aborting!.
...
答案 0 :(得分:1)
如何简单地将测试代码更改为:
public function test__callInvalidRequest()
{
$transmission = new World\Transmission($this->config);
$transmission->foo();
}