public function testGetSetExecutionContext()
 {
     $this->assertEquals(new ExecutionContext(), $this->stepExecution->getExecutionContext());
     $expectedExecutionContext = new ExecutionContext();
     $expectedExecutionContext->put('key', 'value');
     $this->assertEntity($this->stepExecution->setExecutionContext($expectedExecutionContext));
     $this->assertSame($expectedExecutionContext, $this->stepExecution->getExecutionContext());
 }
 /**
  * @dataProvider readItemDatesDataProvider
  *
  * @param string  $dateInContext
  * @param string  $dateInItem
  * @param string  $expectedDate
  * @param boolean $hasData
  * @param string  $dateInIterator
  */
 public function testRead($dateInContext, $dateInItem, $expectedDate, $hasData = true, $dateInIterator = null)
 {
     $iteratorMock = $this->getMock('OroCRM\\Bundle\\MagentoBundle\\Provider\\Iterator\\UpdatedLoaderInterface');
     $connector = $this->getConnector($this->transportMock, $this->stepExecutionMock);
     $this->transportMock->expects($this->at(0))->method($this->getIteratorGetterMethodName())->will($this->returnValue($iteratorMock));
     $connector->setStepExecution($this->stepExecutionMock);
     $context = $this->stepExecutionMock->getExecutionContext();
     $context->put(ConnectorInterface::CONTEXT_CONNECTOR_DATA_KEY, ['lastSyncItemDate' => $dateInContext]);
     $testValue = ['created_at' => '01.01.2200 14:15:08', 'updatedAt' => $dateInItem];
     if ($hasData) {
         $context->put(ConnectorInterface::CONTEXT_CONNECTOR_DATA_KEY, ['lastSyncItemDate' => $dateInContext]);
         $iteratorMock->expects($this->once())->method('rewind');
         $iteratorMock->expects($this->once())->method('next');
         $iteratorMock->expects($this->any())->method('valid')->will($this->onConsecutiveCalls(true, false));
         $iteratorMock->expects($this->once())->method('current')->will($this->returnValue($testValue));
         $this->assertEquals($testValue, $connector->read());
     } else {
         $context->put(ConnectorInterface::CONTEXT_CONNECTOR_DATA_KEY, ['lastSyncItemDate' => $dateInIterator]);
         $iteratorMock->expects($this->once())->method('rewind');
         $iteratorMock->expects($this->never())->method('next');
         $iteratorMock->expects($this->any())->method('valid')->will($this->returnValue(false));
         $iteratorMock->expects($this->never())->method('current')->will($this->returnValue(null));
         $iteratorMock->expects($this->at(0))->method('getStartDate')->will($this->returnValue(new \Datetime($dateInIterator)));
         $iteratorMock->expects($this->at(1))->method('getStartDate')->will($this->returnValue($dateInIterator));
     }
     $this->assertNull($connector->read());
     $connectorData = $context->get(ConnectorInterface::CONTEXT_CONNECTOR_DATA_KEY);
     $this->assertArrayHasKey('lastSyncItemDate', $connectorData);
     if ($hasData) {
         $this->assertSame($expectedDate, $connectorData['lastSyncItemDate']);
     } else {
         $this->assertSame($dateInIterator, $connectorData['lastSyncItemDate']);
     }
 }
 public function testGetStatusData()
 {
     $connector = $this->getConnector($this->transportMock, $this->stepExecutionMock);
     $connector->setStepExecution($this->stepExecutionMock);
     $reflection = new \ReflectionMethod('\\Oro\\Bundle\\IntegrationBundle\\Tests\\Unit\\Stub\\TestConnector', 'addStatusData');
     $reflection->setAccessible(true);
     $reflection->invoke($connector, 'key', 'value');
     $context = $this->stepExecutionMock->getExecutionContext();
     $date = $context->get(ConnectorInterface::CONTEXT_CONNECTOR_DATA_KEY);
     $this->assertArrayHasKey('key', $date);
     $this->assertSame('value', $date['key']);
     $reflection1 = new \ReflectionMethod('\\Oro\\Bundle\\IntegrationBundle\\Tests\\Unit\\Stub\\TestConnector', 'getStatusData');
     $reflection1->setAccessible(true);
     $result = $reflection1->invoke($connector, 'key', 'value');
     $this->assertSame('value', $result);
 }
 /**
  * {@inheritdoc}
  */
 public function getValue($name)
 {
     return $this->stepExecution->getExecutionContext()->get($name);
 }
 /**
  * {@inheritDoc}
  */
 public function getExecutionContext()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getExecutionContext', array());
     return parent::getExecutionContext();
 }