/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Channel is missing */ public function testChannelMissing() { $transport = $this->getMock('OroCRM\\Bundle\\MagentoBundle\\Provider\\Transport\\MagentoTransportInterface'); $this->writer->setTransport($transport); $stepExecution = $this->getMockBuilder('Akeneo\\Bundle\\BatchBundle\\Entity\\StepExecution')->disableOriginalConstructor()->getMock(); $repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository'); $repository->expects($this->any())->method('find')->will($this->returnValue(null)); $this->registry->expects($this->any())->method('getRepository')->will($this->returnValue($repository)); $context = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface'); $context->expects($this->once())->method('getOption')->with($this->equalTo('channel'))->will($this->returnValue(1)); $context->expects($this->once())->method('hasOption')->with($this->equalTo('channel'))->will($this->returnValue(true)); $this->contextRegistry->expects($this->atLeastOnce())->method('getByStepExecution')->with($stepExecution)->will($this->returnValue($context)); $this->writer->setStepExecution($stepExecution); $this->writer->write([['customer_id' => 1]]); }
/** * {@inheritdoc} */ public function write(array $items) { /** @var Address $entity */ $entity = $this->getEntity(); if ($this->stateHandler->isAddressRemoved($entity)) { return; } $item = reset($items); if (!empty($item['region_id'])) { $item['region_id'] = $this->getMagentoRegionIdByCombinedCode($item['region_id']); if (empty($item['region_id'])) { $item['region'] = $entity->getRegionName(); } } if (!$item) { $this->logger->error('Wrong Customer Address data', (array) $item); return; } $this->transport->init($this->getChannel()->getTransport()); if (empty($item[self::CUSTOMER_ADDRESS_ID_KEY])) { $this->writeNewItem($item); } else { $this->writeExistingItem($item); } parent::write([$entity]); }
/** * {@inheritdoc} */ public function write(array $items) { /** @var Customer $entity */ $entity = $this->getEntity(); if ($this->stateHandler->isCustomerRemoved($entity)) { return; } $item = reset($items); if (!$item) { $this->logger->error('Wrong Customer data', (array) $item); return; } $this->transport->init($this->getChannel()->getTransport()); if (empty($item[self::CUSTOMER_ID_KEY])) { $this->writeNewItem($item, $entity); } else { $this->writeExistingItem($item, $entity); } // Clear temporary saved password $entity->setPassword(null); parent::write([$entity]); }