atoum/atoum — pull request #355 by mageekguy (2014-09-29 20:04:27+00:00)
Title: Add mock\generator::disallowUndefinedMethodInInterface()

By default, it's possible to call a method undefined in a mocked interface.
However, in some case, it's a problem because you have no feedback if your tested code use an undefined method in an interface.
This is an example in pseudo-code:
```php
interface foo
{
}

use mock\foo;

class bar extends \atoum
{
function testSomething()
{
$this
->given($foo = new foo)
->if($this->newTestedInstance)
->then
->object($this->testedInstance->something($foo))->isTestedInstance
->mock($foo->call('undefinedMethod')->withIdenticalArguments($this->testedInstance)->once
;
}
}
```
When this code is executed, atoum generate no warning about the fact that `foo::undefinedMethod()` is not defined in `foo` interface, so the user can omit to add in it.
With this patch, the user will be notify by atoum in this case if the method `disallowUndefinedMethodInInterface()` is used:
```
class bar extends \atoum
{
function testSomething()
{
$this
->mockGenerator->disallowUndefinedMethodInInterface()
->given($foo = new foo)
->if($this->newTestedInstance)
->then
->object($this->testedInstance->something($foo))->isTestedInstance
->mock($foo->call('undefinedMethod')->withIdenticalArguments($this->testedInstance)->once
;
}
}

// Failure (1 test, 0/1 method, 0 void method, 0 skipped method, 1 uncompleted method, 0 failure, 1 error, 0 exception)!
// > There is 1 error:
=> bar::testSomething():
==> Error FATAL ERROR in /path/to/tests/units/bar.php on unknown line, generated by file /path/to/bar.php on line X:
Call to undefined method mock\foo::undefinedMethod()
```