Esempio n. 1
0
 protected function setUp()
 {
     $this->contextRegistry = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Context\\ContextRegistry');
     $this->logger = new LoggerStrategy(new NullLogger());
     $this->contextMediator = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Provider\\ConnectorContextMediator')->disableOriginalConstructor()->getMock();
     $this->stepExecutionMock = $this->getMockBuilder('Akeneo\\Bundle\\BatchBundle\\Entity\\StepExecution')->disableOriginalConstructor()->getMock();
     $this->context = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface');
     $this->contextRegistry->expects($this->any())->method('getByStepExecution')->will($this->returnValue($this->context));
     $channel = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Entity\\Channel');
     $transportSettings = $this->getMockForAbstractClass('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport');
     $channel->expects($this->any())->method('getTransport')->will($this->returnValue($transportSettings));
     $this->transport = $this->getMock('OroCRM\\Bundle\\MagentoBundle\\Provider\\Transport\\MagentoTransportInterface');
     $this->contextMediator->expects($this->any())->method('getInitializedTransport')->will($this->returnValue($this->transport));
     $this->contextMediator->expects($this->any())->method('getChannel')->will($this->returnValue($channel));
     $this->executionContext = $this->getMock('Akeneo\\Bundle\\BatchBundle\\Item\\ExecutionContext');
     $this->jobExecution = $this->getMock('Akeneo\\Bundle\\BatchBundle\\Entity\\JobExecution');
     $this->jobExecution->expects($this->any())->method('getExecutionContext')->will($this->returnValue($this->executionContext));
     $this->stepExecutionMock->expects($this->once())->method('getJobExecution')->will($this->returnValue($this->jobExecution));
 }
Esempio n. 2
0
 public function testInitializeAndRead()
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|StepExecution $stepExecution */
     $stepExecution = $this->getMockBuilder('Akeneo\\Bundle\\BatchBundle\\Entity\\StepExecution')->disableOriginalConstructor()->getMock();
     $context = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface');
     $this->contextRegistry->expects($this->once())->method('getByStepExecution')->with($stepExecution)->will($this->returnValue($context));
     $this->executionContext = $this->getMock('Akeneo\\Bundle\\BatchBundle\\Item\\ExecutionContext');
     $this->jobExecution = $this->getMock('Akeneo\\Bundle\\BatchBundle\\Entity\\JobExecution');
     $this->jobExecution->expects($this->any())->method('getExecutionContext')->will($this->returnValue($this->executionContext));
     $data = $this->getData();
     $this->executionContext->expects($this->once())->method('get')->will($this->returnValue($data));
     $stepExecution->expects($this->once())->method('getJobExecution')->will($this->returnValue($this->jobExecution));
     $reader = $this->getReader();
     $reader->setStepExecution($stepExecution);
     foreach ($data as $item) {
         $this->assertEquals($item, $reader->read());
     }
     $this->assertNull($reader->read());
 }