php - PHPUnit fatal error call to undefined method on mock -


i want test method on object called. want making mock of object, rather specific class. following code throws fatal error:

class mytest extends phpunit_framework_testcase {     public function testsomemethodiscalled()     {         $mock = $this->getmock('object');         $mock->expects($this->once())                 ->method('somemethod');         $mock->somemethod();     } } 

the above dies error:

fatal error: call undefined method mock_object_204ac105::somemethod() 

i'm sure there way this, without having write class has somemethod() method?

you must set array of methods should available in mock when create via $this->getmock(), code should work:

$mock = $this->getmock('object', ['somemethod']); 

Comments

Popular posts from this blog

java - unable show chart in xls document using jasper reports -

java.lang.RuntimeException: Could not generate dummy secret at sun.security.ssl.RSAClientKeyExchange.<init> -

javascript - How to change image src on success AJAX -