public function testApiFail_StopsLoopAndDelegatesFailureToSupervisor()
{
$ex = new Exception();
$params = ['param' => 'value'];
$super = $this->getMock(Supervisor::class, [], [], '', false);
$super->expects($this->any())->method('solve')->with($ex, $this->isType('array'))->will($this->returnValue(new PromiseFulfilled()));
$loop = $this->getMock(Loop::class, [], [], '', false);
$loop->expects($this->once())->method('onTick')->will($this->returnCallback(function ($callable) {
$callable();
}));
$runtime = $this->createModel([], ['getSupervisor', 'getLoop', 'setLoopState']);
$runtime->expects($this->once())->method('getSupervisor')->will($this->returnValue($super));
$runtime->expects($this->once())->method('getLoop')->will($this->returnValue($loop));
$runtime->expects($this->once())->method('setLoopState')->with(RuntimeModel::LOOP_STATE_FAILED);
$runtime->fail($ex, $params);
}