/** * Tests PipelineStarter. */ public function testPipelineStarter() { /** @var PipelineInterface|\PHPUnit_Framework_MockObject_MockObject $pipeline */ $pipeline = $this->getMockForAbstractClass('ONGR\\ConnectionsBundle\\Pipeline\\PipelineInterface'); $pipeline->expects($this->once())->method('start'); /** @var PipelineFactory|\PHPUnit_Framework_MockObject_MockObject $factory */ $factory = $this->getMock('ONGR\\ConnectionsBundle\\Pipeline\\PipelineFactory'); $factory->expects($this->once())->method('create')->with('prefix_target')->willReturn($pipeline); $starter = new PipelineStarter(); $starter->setPipelineFactory($factory); $starter->startPipeline('prefix_', 'target'); }
/** * Test event dispatching. */ public function testPipelineEventDispatching() { $pipelineName = 'some-target'; /** @var EventDispatcherInterface|MockObject $dispatcher */ $dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface'); $dispatcher->expects($this->exactly(3))->method('dispatch')->withConsecutive(['ongr.pipeline.data_sync.' . $pipelineName . '.source', $this->anything()], ['ongr.pipeline.data_sync.' . $pipelineName . '.start', $this->anything()], ['ongr.pipeline.data_sync.' . $pipelineName . '.finish', $this->anything()], ['ongr.pipeline.data_sync.' . $pipelineName . '.consume', $this->anything()], ['ongr.pipeline.data_sync.' . $pipelineName . '.modify', $this->anything()]); $dataSyncService = new PipelineStarter(); $pipelineFactory = new PipelineFactory(); $pipelineFactory->setDispatcher($dispatcher); $pipelineFactory->setClassName('ONGR\\ConnectionsBundle\\Pipeline\\Pipeline'); $dataSyncService->setPipelineFactory($pipelineFactory); $dataSyncService->startPipeline('data_sync.', $pipelineName); }