php - PHPUnit error call to undefined method on mock -
i getting error: call undefined method mock_simpleinterface_8a93e777::mymethod() when call mymethod() on 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 phpunit docs (https://phpunit.de/manual/5.1/en/test-doubles.html), states "by default, methods of original class replaced dummy implementation returns null (without calling original method)."
shouldn't able call mymethod() , null return value? want avoid specify class methods. phpunit should clever enough know methods can called on mock or not.
is bug? i'm using phpunit 5.1.4
your assumptions correct, have error somewhere else or did not show real code.
the mock class name mock_simpleinterface_8a93e777
suggests don't mock \playground\simple
rather \playground\simpleinterface
, not contain mymethod()
Comments
Post a Comment