Reputation: 15007
public function __call($method, $args)
{
if ( ! in_array($method, $this->validMethods))
{
throw new \BadMethodCallException("Not a valid method: {$method}");
}
}
How do I test the __call
method to make sure $method
is in my list of valid methods? Right now here's what I did;
/**
* @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'));
}
The error I get is a endless trace of call_user_func_array()
.
Maximum function nesting level of '100' reached, aborting!.
...
Upvotes: 0
Views: 392
Reputation: 9082
what about simply change your test code to like these:
public function test__callInvalidRequest()
{
$transmission = new World\Transmission($this->config);
$transmission->foo();
}
Upvotes: 1