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

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -