Is the code actually executed when using a Mockery spy?

Viewed 158

I am trying to write some tests with a Mockery Spy. However, it doesn't seem like the "spied upon" code is executed when I'm using a spy.

Is the code actually executed when using a Mockery spy?

Here is what I tested:

// In my test:
$spy = $this->spy(FeedManager::class);

// Controller
resolve(FeedManager::class)->createResponse();

// FeedManger::createResponse()
public static function createResponse(Builder $builder)
{
  dd("here i am"); // this never gets called unless I remove the spy
}
1 Answers

Apparently, the "spy code" is not supposed to run. Found this quote from the docs.

The \Mockery::spy() method call is actually a shorthand for calling \Mockery::mock()->shouldIgnoreMissing(). The shouldIgnoreMissing method is a “behaviour modifier”.

Related