I'm mocking an object and writing a test like so...
public function test_mocked_object(){
$purchase = new Purchase();
$purchase_m = \Mockery::mock($purchase);
$purchase_m->shouldReceive('internalMethod')->andReturn('GOLD');
$purchase_m->testMethod('test');
}
testMethod()
contains a call to internalMethod()
, like so...
public function testMethod($string){
$this->internalMethod();
}
... but by the time execution reaches the call to $this->internalMethod()
, $this
is now an instance of the original $purchase
object, and not an instance of the $purchase_m
mocked object.
Therefore, the function call to $this->internalMethod()
does not return "GOLD" as we were hoping.
Any pointers would be greatly appreciated.