/** * @dataProvider itemsProvider * * @param array $items * @param array $expectedItems */ public function testWrite(array $items, array $expectedItems) { $this->wrapped->expects($this->once())->method('write')->with($this->equalTo($expectedItems)); $stepExecution = $this->getMockBuilder('Akeneo\\Bundle\\BatchBundle\\Entity\\StepExecution')->disableOriginalConstructor()->getMock(); $this->databaseHelper->expects($this->once())->method('onClear'); $this->writer->setStepExecution($stepExecution); $this->writer->write($items); }
/** * Verify if the writer is usable or not * * @param ItemWriterInterface $writer * * @return bool */ protected function isUsableWriter(ItemWriterInterface $writer) { if ($writer instanceof ArchivableWriterInterface && count($writer->getWrittenFiles()) > 1) { return false; } elseif ($writer instanceof FileWriter && is_file($writer->getPath())) { return true; } return false; }
/** * @param array $processedItems * * @return null */ protected function write($processedItems) { try { $this->writer->write($processedItems); } catch (InvalidItemException $e) { $this->handleStepExecutionWarning($this->stepExecution, $this->writer, $e); } }
/** * @param array $processedItems * @param StepExecutionWarningHandlerInterface|null $warningHandler * * @return null */ protected function write($processedItems, StepExecutionWarningHandlerInterface $warningHandler = null) { try { $this->writer->write($processedItems); } catch (InvalidItemException $e) { $this->handleStepExecutionWarning($this->writer, $e, $warningHandler); } }
/** * {@inheritdoc} */ public function restoreStepExecution() { if ($this->writer instanceof StepExecutionRestoreInterface) { $this->writer->restoreStepExecution(); } }
/** * Verify if the writer is usable or not * * @param ItemWriterInterface $writer * * @return bool */ protected function isWriterUsable(ItemWriterInterface $writer) { return $writer instanceof FileWriter && $writer instanceof ArchivableWriterInterface && count($writer->getWrittenFiles()) > 1; }
/** * {@inheritdoc} */ public function setStepExecution(StepExecution $stepExecution) { if ($this->writer instanceof StepExecutionAwareInterface) { $this->writer->setStepExecution($stepExecution); } }