'Mockery\Exception\BadMethodCallException: Method Mockery_0_MyClass::shouldRecieve() does not exist on this mock object
I am having trouble setting up Mockery to work in my application. I need to make a partial mockery of a library class that has a few functions in it that need to be mocked while other functions are tested. It seems like its failing to pick up the basic ShouldRecieve() function from mockery and instead trying to dig through MyClass for an instance of it. I've created an example of what is going on below.
<?php
class MyClass {
function foo() { return $this->bar; } // to be tested
function bar() { return true; } // to be mocked
}
class MyClass_Test extends TestCase {
function testMyClassFoo() {
$mock = \Mockery::mock('MyClass')->makePartial();
$mock->shouldRecieve('bar')->once()->andReturn(true);
$result = $mock->foo();
$this->assertTrue($result);
}
}
When I try to run the tests I'll get the following error:
Mockery\Exception\BadMethodCallException: Method Mockery_0_MyClass::shouldRecieve() does not exist on this mock object
I am thinking there must be something wrong with the Mockery installation but it all seems to be there. Any ideas why this might happen?
Solution 1:[1]
I know you've provided an example but I'm assuming your error is the real thing.
The method is shouldReceive().
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dan |
