Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mockery throw on first then return value on second call

$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);
like image 405
Zhianc Avatar asked Jul 20 '13 22:07

Zhianc


1 Answers

$client->shouldReceive('send')->once()->andThrow($error);
$client->shouldReceive('send')->once()->andReturn(true);
like image 98
Robbo Avatar answered Oct 23 '22 03:10

Robbo