@talinon so sorry to come back to this, but now I have written the full test, I seem to be having the same issue again.
Firstly, I have updated Mockery as you suggested and that is now all working fine as we had it above. Thank you.
Now the real test looks like this:
$mock = Mockery::mock(IntercomGateway::class)->makePartial();
$mock->shouldReceive('createUser')->andReturn('mocked');
$this->app->instance(IntercomGateway::class, $mock);
$user = $this->createTestUser();
$loginCredentials = [
'email' => $user->email,
'password' => 'wrong_password',
];
$this->fromUrl(route('login'))
->post('/login', $loginCredentials)
->assertEIMErrorExists('login_fail');
The test passes fine, but still calls the original createUser() method in the IntercomGateway class, not the mocked one.
So when I run this test I now see the dump Original method executed as before. The createTestUser() method sets up a user just for the purposes of the test, but also creates a new Intercom user which is the bit I want to mock as it's not relevant to the test.
So sorry to ask you again, but would appreciate your thoughts on what I might be doing wrong here.
Thank you!