嘲弄先抛出,然后在第二次调用时返回值


Mockery throw on first then return value on second call

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

不幸的是,它只返回 true,但不首先抛出异常。如何在第一次调用时引发异常,然后在第二次调用该方法时返回值?

编辑

如果我手动编辑Mockery'Expectation.php并设置$_throw = true,这有效。

$client->shouldReceive('send')->twice()->andReturn($error, true);
$client->shouldReceive('send')->once()->andThrow($error);
$client->shouldReceive('send')->once()->andReturn(true);