function it_executes_with_an_invalid_item_during_processing($reader, $processor, $writer, StepExecution $execution, EventDispatcherInterface $dispatcher, JobRepositoryInterface $repository, BatchStatus $status, ExitStatus $exitStatus) { $this->setBatchSize(3); $this->setEventDispatcher($dispatcher); $this->setJobRepository($repository); $execution->getStatus()->willReturn($status); $status->getValue()->willReturn(BatchStatus::STARTING); $dispatcher->dispatch(EventInterface::BEFORE_STEP_EXECUTION, Argument::any())->shouldBeCalled(); $execution->setStartTime(Argument::any())->shouldBeCalled(); $execution->setStatus(Argument::any())->shouldBeCalled(); // first batch $reader->read()->willReturn('r1', 'r2', 'r3', 'r4', null); $processor->process('r1')->shouldBeCalled()->willReturn('p1'); $processor->process('r2')->shouldBeCalled()->willReturn('p2'); $processor->process('r3')->shouldBeCalled()->willReturn('p3'); $writer->write(['p1', 'p2', 'p3'])->shouldBeCalled(); // second batch $processor->process('r4')->shouldBeCalled()->willThrow(new InvalidItemException('my msg', ['r4'])); $execution->addWarning(Argument::any(), Argument::any(), Argument::any(), Argument::any())->shouldBeCalled(); $dispatcher->dispatch(Argument::any(), Argument::any())->shouldBeCalled(); $processor->process(null)->shouldNotBeCalled(); $writer->write(['p4'])->shouldNotBeCalled(); $execution->getExitStatus()->willReturn($exitStatus); $exitStatus->getExitCode()->willReturn(ExitStatus::COMPLETED); $repository->updateStepExecution($execution)->shouldBeCalled(); $execution->isTerminateOnly()->willReturn(false); $execution->upgradeStatus(Argument::any())->shouldBeCalled(); $dispatcher->dispatch(EventInterface::STEP_EXECUTION_SUCCEEDED, Argument::any())->shouldBeCalled(); $dispatcher->dispatch(EventInterface::STEP_EXECUTION_COMPLETED, Argument::any())->shouldBeCalled(); $execution->setEndTime(Argument::any())->shouldBeCalled(); $execution->setExitStatus(Argument::any())->shouldBeCalled(); $this->execute($execution); }