I am getting Error: Call to undefined method Mock_SimpleInterface_8a93e777::mymethod() when I call the mymethod() on the Simple class mock.
class PlaygroundTest extends \PHPUnit_Framework_TestCase
{
public function testMock()
{
$class = $this->getMockBuilder('\Playground\Simple')->getMock();
$class->mymethod();
}
}
The Simple class implementation
namespace Playground;
class Simple
{
public function mymethod()
{
print "Hey!";
}
}
According to PHPUnit docs (https://phpunit.de/manual/5.1/en/test-doubles.html), it states that "By default, all methods of the original class are replaced with a dummy implementation that just returns null (without calling the original method)."
Shouldn't I be able to call mymethod() and get a null return value? I want to avoid to specify all class methods. PHPUnit should be clever enough to know which methods can be called on the mock or not.
Is this a bug? I'm using PHPUnit 5.1.4
$classbut callingmymethod()on$interface. Is it really like this or a mistake in your question? - ArSeNOK (1 test, 0 assertions)is the result. The problem has to be elsehwere. Do you have a call stack, with which you could verify where the call is actually coming from? - ArSeN