首先嘲笑投掷,然后在第二次调用时返回值

2022-08-30 21:00:54
$client = Mockery::mock();
$client->shouldReceive('send')->andThrow($error)->andReturn(true);

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

编辑

如果我手动编辑并设置.c,这将起作用。Mockery\Expectation.php$_throw = true

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

答案 1
$client->shouldReceive('send')->once()->andThrow($error);
$client->shouldReceive('send')->once()->andReturn(true);

答案 2

推荐