public function testProcessGoodScenario() { $testWebsiteId = 1; $testStoreId = 2; $testStoresArray = new \ArrayIterator([['website_id' => $testWebsiteId, 'store_id' => $testStoreId]]); $settingBag = new ParameterBag(['website_id' => $testWebsiteId]); $testData = [['id' => 1, 'originId' => 11], ['id' => 2, 'originId' => 22], ['id' => 3, 'originId' => 33]]; $testExistedCarts = [(object) ['entity_id' => 22]]; $repo = $this->getMockBuilder('OroCRM\\Bundle\\MagentoBundle\\Entity\\Repository\\CartRepository')->disableOriginalConstructor()->getMock(); $this->em->expects($this->any())->method('getRepository')->with('OroCRMMagentoBundle:Cart')->will($this->returnValue($repo)); $transport = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport')->setMethods(['getSettingsBag'])->getMockForAbstractClass(); $transport->expects($this->any())->method('getSettingsBag')->will($this->returnValue($settingBag)); $realTransport = $this->getMock('OroCRM\\Bundle\\MagentoBundle\\Provider\\Transport\\MagentoTransportInterface'); $realTransport->expects($this->once())->method('isSupportedExtensionVersion')->will($this->returnValue(true)); $realTransport->expects($this->once())->method('getStores')->will($this->returnValue($testStoresArray)); $this->helper->expects($this->once())->method('getTransport')->will($this->returnValue($realTransport)); $channel = new Channel(); $channel->setTransport($transport); $realTransport->expects($this->at(3))->method('call')->with(SoapTransport::ACTION_ORO_CART_LIST, ['filters' => ['complex_filter' => [['key' => 'store_id', 'value' => ['key' => 'in', 'value' => $testStoreId]], ['key' => 'entity_id', 'value' => ['key' => 'in', 'value' => '11,22']]]], 'pager' => ['page' => 1, 'pageSize' => self::BATCH_SIZE]])->will($this->returnValue($testExistedCarts)); $realTransport->expects($this->at(4))->method('call')->with(SoapTransport::ACTION_ORO_CART_LIST, ['filters' => ['complex_filter' => [['key' => 'store_id', 'value' => ['key' => 'in', 'value' => $testStoreId]], ['key' => 'entity_id', 'value' => ['key' => 'in', 'value' => '33']]]], 'pager' => ['page' => 1, 'pageSize' => self::BATCH_SIZE]])->will($this->returnValue([])); $repo->expects($this->once())->method('getCartsByChannelIdsIterator')->with($channel)->will($this->returnValue($testData)); $repo->expects($this->at(1))->method('markExpired')->with([1]); $repo->expects($this->at(2))->method('markExpired')->with([3]); $this->processor->process($channel); }
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)); }