Пример #1
0
 /**
  * @dataProvider testProcessDataProvider
  */
 public function testProcess($data, $expected)
 {
     $this->integration->expects($this->once())->method('getConnectors')->willReturn($data['integrationConnectors']);
     $this->integration->expects($this->any())->method('getId')->willReturn($data['channel']);
     $this->integration->expects($this->atLeastOnce())->method('getType')->willReturn($data['integrationType']);
     $this->integration->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->registry->expects($this->any())->method('getConnectorType')->willReturnMap($data['realConnectorsMap']);
     $this->processorRegistry->expects($this->any())->method('getProcessorAliasesByEntity')->willReturn([]);
     $jobResult = new JobResult();
     $jobResult->setContext(new TestContext());
     $jobResult->setSuccessful(true);
     $mocker = $this->jobExecutor->expects($this->exactly(count($expected)))->method('executeJob');
     call_user_func_array([$mocker, 'withConsecutive'], $expected);
     $mocker->willReturn($jobResult);
     $processor = $this->getSyncProcessor();
     $processor->process($this->integration, $data['connector'], $data['parameters']);
 }
 public function testOneIntegrationConnectorProcess()
 {
     $connector = 'testConnector';
     $this->integration->expects($this->never())->method('getConnectors');
     $this->integration->expects($this->once())->method('getId')->will($this->returnValue('testChannel'));
     $expectedAlias = 'test_alias';
     $this->processorRegistry->expects($this->once())->method('getProcessorAliasesByEntity')->with(ProcessorRegistry::TYPE_EXPORT)->will($this->returnValue(array($expectedAlias)));
     $realConnector = new TestConnector();
     $this->registry->expects($this->once())->method('getConnectorType')->will($this->returnValue($realConnector));
     $this->integration->expects($this->once())->method('getEnabled')->will($this->returnValue(true));
     $jobResult = new JobResult();
     $jobResult->setContext(new TestContext());
     $jobResult->setSuccessful(true);
     $this->jobExecutor->expects($this->once())->method('executeJob')->with('export', 'tstJobName', ['export' => ['entityName' => 'testEntity', 'channel' => 'testChannel', 'processorAlias' => $expectedAlias, 'testParameter' => 'testValue']])->will($this->returnValue($jobResult));
     $processor = $this->getReverseSyncProcessor();
     $processor->process($this->integration, $connector, ['testParameter' => 'testValue']);
 }
Пример #3
0
 public function testOneChannelConnectorProcess()
 {
     $connector = 'testConnector';
     $connectors = [$connector];
     $this->integration->expects($this->once())->method('getConnectors')->will($this->returnValue($connectors));
     $this->integration->expects($this->once())->method('getId')->will($this->returnValue('testChannel'));
     $this->integration->expects($this->atLeastOnce())->method('getType')->will($this->returnValue('testChannelType'));
     $this->integration->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
     $realConnector = new TestConnector();
     $this->registry->expects($this->once())->method('getConnectorType')->will($this->returnValue($realConnector));
     $this->processorRegistry->expects($this->once())->method('getProcessorAliasesByEntity')->will($this->returnValue([]));
     $jobResult = new JobResult();
     $jobResult->setContext(new TestContext());
     $jobResult->setSuccessful(true);
     $this->jobExecutor->expects($this->once())->method('executeJob')->with('import', 'test job', ['import' => ['processorAlias' => false, 'entityName' => 'testEntity', 'channel' => 'testChannel', 'channelType' => 'testChannelType', 'testParameter' => 'testValue']])->will($this->returnValue($jobResult));
     $processor = $this->getSyncProcessor();
     $processor->process($this->integration, $connector, ['testParameter' => 'testValue']);
 }