function it_keeps_the_operation_in_the_buffer_if_it_fails(OperationBuffer $buffer, OperationRunner $runner, Operation $operation) { $runner->run($operation)->willThrow(new \RuntimeException('Unable to run the operation')); $buffer->current()->willReturn($operation); $this->shouldThrow(\RuntimeException::class)->duringRun($operation); $buffer->pop()->shouldNotBeCalled(); }
/** * {@inheritdoc} */ public function run(Operation $operation) { $this->buffer->add($operation); while (null !== ($operation = $this->buffer->current())) { $this->runner->run($operation); $this->buffer->pop(); } }
/** * Runs the buffered operations. * * It returns an array of results. * * @return mixed[] */ public function runBufferedOperations() { $results = []; while (null !== ($operation = $this->buffer->current())) { $results[] = $this->runner->run($operation); $this->buffer->pop(); } return $results; }