/** * {@inheritdoc} */ public function load(ObjectManager $manager) { foreach ($this->data as $data) { $status = new Status(); $status->setChannel($this->getReference($data['channel'])); $status->setCode($data['status']); $status->setConnector($data['connector']); $status->setDate(new \DateTime($data['date'], new \DateTimeZone('UTC'))); $status->setMessage($data['message']); $this->setReference($data['reference'], $status); $manager->persist($status); } $manager->flush(); }
public function testSkippedIfSyncedDuringConfiguredInterval() { $transport = $this->getMock('OroCRM\\Bundle\\MagentoBundle\\Provider\\Transport\\MagentoTransportInterface'); $channel = new Channel(); $connector = $this->getConnector($this->transportMock, $this->stepExecutionMock, $channel); $status = new Status(); $status->setCode($status::STATUS_COMPLETED); $status->setConnector($connector->getType()); $status->setDate(new \DateTime('-10 minutes', new \DateTimeZone('UTC'))); $this->expectLastCompletedStatusForConnector($status, $channel, $connector->getType()); $connector->setStepExecution($this->stepExecutionMock); $transport->expects($this->never())->method('getRegions'); $this->assertInstanceOf('\\EmptyIterator', $connector->getSourceIterator()); }
/** * @param ChannelRepository $repository * @param Channel $integration * @param string $connector */ protected function addInitialStatus(ChannelRepository $repository, Channel $integration, $connector) { /** @var MagentoSoapTransport $transport */ $transport = $integration->getTransport(); $syncStartDate = $transport->getSyncStartDate(); $now = new \DateTime('now', new \DateTimeZone('UTC')); $status = new Status(); $status->setData([AbstractInitialProcessor::INITIAL_SYNCED_TO => $syncStartDate->format(\DateTime::ISO8601)]); $status->setConnector($connector); $status->setDate($now); $status->setChannel($integration); $status->setCode(Status::STATUS_COMPLETED); $status->setMessage('Automatically added initial connector status.'); $repository->addStatus($integration, $status); }
public function testInitializationInUpdatedMode() { $channel = new Channel(); $connector = $this->getConnector($this->transportMock, $this->stepExecutionMock, $channel); $status = new Status(); $status->setCode($status::STATUS_COMPLETED); $status->setConnector($connector->getType()); $status->setDate(new \DateTime('-10 days', new \DateTimeZone('UTC'))); $this->expectLastCompletedStatusForConnector($status, $channel, $connector->getType()); $expectedDateInFilter = clone $status->getDate(); $assumptionInterval = $this->config['sync_settings']['mistiming_assumption_interval']; $expectedDateInFilter->sub(\DateInterval::createFromDateString($assumptionInterval)); $iterator = $this->getMock('OroCRM\\Bundle\\MagentoBundle\\Provider\\Iterator\\UpdatedLoaderInterface'); $iterator->expects($this->once())->method('setStartDate')->with($this->equalTo($expectedDateInFilter)); $this->transportMock->expects($this->at(0))->method($this->getIteratorGetterMethodName())->will($this->returnValue($iterator)); $connector->setStepExecution($this->stepExecutionMock); }