Mockery throw on first then return value on second call
Asked Answered
I

1

21
$client = Mockery::mock();
$client->shouldReceive('send')->andThrow($error)->andReturn(true);

Unfortunately it only returns true but not throw the exception first. How do I throw an exception on first call then return value on second call of the method?

EDIT:

This works if I manually edit Mockery\Expectation.php and set $_throw = true.

$client->shouldReceive('send')->twice()->andReturn($error, true);
Ic answered 20/7, 2013 at 22:21 Comment(0)
C
37
$client->shouldReceive('send')->once()->andThrow($error);
$client->shouldReceive('send')->once()->andReturn(true);
Coumarin answered 21/7, 2013 at 0:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.