示例#1
0
 public function testDispatchWriteInvalidItemException()
 {
     $stepExecution = $this->getMockBuilder('Akeneo\\Bundle\\BatchBundle\\Entity\\StepExecution')->disableOriginalConstructor()->getMock();
     $stepExecution->expects($this->any())->method('getStatus')->will($this->returnValue(new BatchStatus(BatchStatus::STARTING)));
     $stepExecution->expects($this->any())->method('getExitStatus')->will($this->returnValue(new BatchStatus(BatchStatus::STARTED)));
     $this->eventDispatcher->expects($this->at(1))->method('dispatch')->with(EventInterface::INVALID_ITEM, $this->logicalAnd($this->isInstanceOf('Akeneo\\Bundle\\BatchBundle\\Event\\InvalidItemEvent'), $this->attributeEqualTo('reason', 'The written item is invalid'), $this->attributeEqualTo('item', array('foo' => 'bar'))));
     $reader = $this->getMock('Akeneo\\Bundle\\BatchBundle\\Tests\\Unit\\Step\\Stub\\ReaderStub');
     $reader->expects($this->exactly(2))->method('read')->will($this->onConsecutiveCalls($this->returnValue(array('foo' => 'bar')), $this->returnValue(null)));
     $processor = $this->getMock('Akeneo\\Bundle\\BatchBundle\\Tests\\Unit\\Item\\ItemProcessorTestHelper');
     $processor->expects($this->exactly(1))->method('process')->will($this->returnValue(array('foo' => 'bar')));
     $writer = $this->getMock('Akeneo\\Bundle\\BatchBundle\\Tests\\Unit\\Item\\ItemWriterTestHelper');
     $writer->expects($this->exactly(1))->method('write')->will($this->throwException(new InvalidItemException('The written item is invalid', array('foo' => 'bar'))));
     $writer->expects($this->any())->method('getName')->will($this->returnValue('stub_writer'));
     $this->itemStep->setReader($reader);
     $this->itemStep->setProcessor($processor);
     $this->itemStep->setWriter($writer);
     $stepExecution->expects($this->once())->method('addWarning')->with('stub_writer', 'The written item is invalid', array(), array('foo' => 'bar'));
     $this->itemStep->setBatchSize(5);
     $this->itemStep->execute($stepExecution);
 }
示例#2
0
 public function getItemStep($name, $reader, $processor, $writer)
 {
     $itemStep = new ItemStep($name);
     $itemStep->setReader($reader);
     $itemStep->setProcessor($processor);
     $itemStep->setWriter($writer);
     return $itemStep;
 }