public function testGetLastStatusForConnectorWorks()
 {
     $fooIntegration = $this->getReference('oro_integration:foo_integration');
     $this->assertSame($this->getReference('oro_integration:foo_first_connector_second_status_completed'), $this->repository->getLastStatusForConnector($fooIntegration, 'first_connector', Status::STATUS_COMPLETED));
     $this->assertSame($this->getReference('oro_integration:foo_first_connector_third_status_failed'), $this->repository->getLastStatusForConnector($fooIntegration, 'first_connector', Status::STATUS_FAILED));
     $barIntegration = $this->getReference('oro_integration:bar_integration');
     $this->assertSame($this->getReference('oro_integration:bar_first_connector_first_status_completed'), $this->repository->getLastStatusForConnector($barIntegration, 'first_connector', Status::STATUS_COMPLETED));
 }
 /**
  * @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);
 }
Esempio n. 3
0
 /**
  * @dataProvider channelsTypeProvider
  *
  * @param null|string $type
  */
 public function testGetConfiguredChannelsForSync($type = null)
 {
     $expectedResult = [];
     $query = $this->getMockBuilder('Doctrine\\ORM\\AbstractQuery')->disableOriginalConstructor()->setMethods(array('getResult'))->getMockForAbstractClass();
     $query->expects($this->once())->method('getResult')->will($this->returnValue($expectedResult));
     $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock();
     $qb->expects($this->at(0))->method('select')->with('c')->will($this->returnSelf());
     $qb->expects($this->at(1))->method('from')->with('Oro\\Bundle\\IntegrationBundle\\Entity\\Channel')->will($this->returnSelf());
     $qb->expects($this->at(2))->method('where')->with('c.transport is NOT NULL')->will($this->returnSelf());
     $qb->expects($this->at(3))->method('andWhere')->with('c.enabled = :isEnabled')->will($this->returnSelf());
     $qb->expects($this->at(4))->method('setParameter')->with('isEnabled', true)->will($this->returnSelf());
     if (null !== $type) {
         $qb->expects($this->at(5))->method('andWhere')->with('c.type = :type')->will($this->returnSelf());
         $qb->expects($this->at(6))->method('setParameter')->with('type', $type)->will($this->returnSelf());
     }
     $qb->expects($this->once())->method('getQuery')->will($this->returnValue($query));
     $this->entityManager->expects($this->once())->method('createQueryBuilder')->with()->will($this->returnValue($qb));
     $result = $this->repository->getConfiguredChannelsForSync($type);
     $this->assertSame($expectedResult, $result);
 }
Esempio n. 4
0
 /**
  * @param \PHPUnit_Framework_MockObject_MockObject $integration
  * @param string $connector
  * @param null|object $status
  */
 protected function assertConnectorStatusCall($integration, $connector, $status = null)
 {
     $this->repository->expects($this->atLeastOnce())->method('getLastStatusForConnector')->with($integration, $connector)->will($this->returnValue($status));
 }
 /**
  * @dataProvider getRunningSyncJobsCountDataProvider
  *
  * @param string        $command
  * @param int           $expectedCount
  * @param null|string   $integration
  */
 public function testGetRunningSyncJobsCount($command, $expectedCount, $integration = null)
 {
     $integration = $integration ? $this->getReference($integration)->getId() : null;
     $actual = $this->repository->getRunningSyncJobsCount($command, $integration);
     $this->assertEquals($expectedCount, $actual);
 }
Esempio n. 6
0
 /**
  * @param Status $expectedStatus
  * @param Channel $channel
  * @param string $connector
  */
 protected function expectLastCompletedStatusForConnector($expectedStatus, $channel, $connector)
 {
     $this->integrationRepositoryMock->expects($this->once())->method('getLastStatusForConnector')->with($channel, $connector, Status::STATUS_COMPLETED)->will($this->returnValue($expectedStatus));
 }