public function testSetDefaultOptions()
 {
     /** @var OptionsResolverInterface|\PHPUnit_Framework_MockObject_MockObject $resolver */
     $resolver = $this->getMock('Symfony\\Component\\OptionsResolver\\OptionsResolverInterface');
     $resolver->expects($this->once())->method('setDefaults')->with($this->isType('array'));
     $this->registry->expects($this->once())->method('getAvailableIntegrationTypesDetailedData')->will($this->returnValue(['testType1' => ["label" => "oro.type1.label", "icon" => "bundles/acmedemo/img/logo.png"], 'testType2' => ["label" => "oro.type2.label"]]));
     $this->assetHelper->expects($this->once())->method('getUrl')->will($this->returnArgument(0));
     $this->type->setDefaultOptions($resolver);
 }
 public function testGetTransportFromContext()
 {
     $testID = 1;
     $testTransport = new \stdClass();
     $integration = new Integration();
     $integration->setTransport($this->getMockForAbstractClass('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport'));
     $context = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface');
     $context->expects($this->once())->method('getOption')->with('channel')->will($this->returnValue($testID));
     $this->repo->expects($this->once())->method('getOrLoadById')->with($testID)->will($this->returnValue($integration));
     $this->registry->expects($this->once())->method('getTransportTypeBySettingEntity')->will($this->returnValue($testTransport));
     $result = $this->contextMediator->getTransport($context);
     $this->assertEquals($testTransport, $result);
 }
 public function testSetDefaultOptions()
 {
     $resolver = new OptionsResolver();
     $this->registry->expects($this->once())->method('getAvailableIntegrationTypesDetailedData')->will($this->returnValue(['testType1' => ['label' => 'oro.type1.label', 'icon' => 'bundles/acmedemo/img/logo.png'], 'testType2' => ['label' => 'oro.type2.label']]));
     $this->assetHelper->expects($this->once())->method('getUrl')->will($this->returnArgument(0));
     $this->type->setDefaultOptions($resolver);
     $result = $resolver->resolve([]);
     $choiceAttr = [];
     foreach ($result['choices'] as $choice => $label) {
         $choiceAttr[$choice] = call_user_func($result['choice_attr'], $choice);
     }
     unset($result['choice_attr']);
     $this->assertEquals(['empty_value' => '', 'choices' => ['testType1' => 'oro.type1.label', 'testType2' => 'oro.type2.label'], 'configs' => ['placeholder' => 'oro.form.choose_value', 'result_template_twig' => 'OroIntegrationBundle:Autocomplete:type/result.html.twig', 'selection_template_twig' => 'OroIntegrationBundle:Autocomplete:type/selection.html.twig']], $result);
     $this->assertEquals(['testType1' => ['data-icon' => 'bundles/acmedemo/img/logo.png'], 'testType2' => []], $choiceAttr);
 }
 public function testFinishView()
 {
     $this->registry->expects($this->once())->method('getAvailableIntegrationTypesDetailedData')->will($this->returnValue(['testType1' => ["label" => "oro.type1.label", "icon" => "bundles/acmedemo/img/logo.png"], 'testType2' => ["label" => "oro.type2.label"]]));
     $this->assetHelper->expects($this->once())->method('getUrl')->will($this->returnArgument(0));
     $testIntegration1 = new Integration();
     $testIntegration1->setType('testType1');
     $testIntegration1Label = uniqid('label');
     $testIntegration1Id = uniqid('id');
     $testIntegration2 = new Integration();
     $testIntegration2->setType('testType2');
     $testIntegration2Label = uniqid('label');
     $testIntegration2Id = uniqid('id');
     $view = new FormView();
     $view->vars['choices'] = [new ChoiceView($testIntegration1, $testIntegration1Id, $testIntegration1Label), new ChoiceView($testIntegration2, $testIntegration2Id, $testIntegration2Label)];
     $this->type->finishView($view, $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface'), []);
     $this->assertEquals($testIntegration1Label, $view->vars['choices'][0]->label);
     $this->assertEquals($testIntegration2Label, $view->vars['choices'][1]->label);
     $this->assertEquals(['data-status' => true, 'data-icon' => 'bundles/acmedemo/img/logo.png'], $view->vars['choices'][0]->attr);
 }
 public function testOnChannelSucceedSave()
 {
     $this->entity->setChannelType(ChannelType::TYPE);
     $transport = new MagentoSoapTransport();
     $transport->setIsExtensionInstalled(false);
     $this->integration->setTransport($transport);
     $this->typesRegistry->expects($this->any())->method('getRegisteredConnectorsTypes')->willReturn(new ArrayCollection([]));
     $this->prepareEvent();
     $this->getListener()->onChannelSucceedSave($this->event);
 }
 public function testPreSetWithBusinessUnitDefaultOwnerTypeAndExistingSameField()
 {
     $integration = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Entity\\Channel');
     $integration->expects($this->any())->method('getType')->will($this->returnValue('integration_type'));
     $this->typesRegistry->expects($this->any())->method('getDefaultOwnerType')->with($this->equalTo('integration_type'))->will($this->returnValue(DefaultOwnerTypeAwareInterface::BUSINESS_UNIT));
     $form = $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface');
     $form->expects($this->at(0))->method('has')->with($this->equalTo('defaultUserOwner'))->will($this->returnValue(false));
     $form->expects($this->at(1))->method('has')->with($this->equalTo('defaultBusinessUnitOwner'))->will($this->returnValue(true));
     $form->expects($this->never())->method('add');
     $event = new FormEvent($form, $integration);
     $this->subscriber->preSet($event);
 }
 public function testGetInitializedTransport()
 {
     $testTransport = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Provider\\TransportInterface');
     $transportEntity = $this->getMockForAbstractClass('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport');
     $integration = new Integration();
     $integration->setTransport($transportEntity);
     $this->registry->expects($this->once())->method('getTransportTypeBySettingEntity')->will($this->returnValue($testTransport));
     $testTransport->expects($this->once())->method('init')->with($transportEntity);
     $result = $this->contextMediator->getInitializedTransport($integration);
     $this->assertEquals($testTransport, $result);
     // test local cache
     $this->contextMediator->getInitializedTransport($integration);
 }
Exemplo n.º 8
0
 /**
  * @param array $connectors
  * @param \DateTime $syncStartDate
  * @param object|null $realConnector
  * @return Channel|\PHPUnit_Framework_MockObject_MockObject
  */
 protected function getIntegration(array $connectors = [], \DateTime $syncStartDate = null, $realConnector = null)
 {
     $integration = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Entity\\Channel')->disableOriginalConstructor()->getMock();
     $integration->expects($this->any())->method('getConnectors')->will($this->returnValue($connectors));
     $integration->expects($this->any())->method('getId')->will($this->returnValue('testChannel'));
     $integration->expects($this->any())->method('getType')->will($this->returnValue('testChannelType'));
     $transport = new MagentoSoapTransport();
     if ($syncStartDate) {
         $transport->setSyncStartDate($syncStartDate);
     }
     $integration->expects($this->any())->method('getTransport')->will($this->returnValue($transport));
     $integration->expects($this->any())->method('isEnabled')->will($this->returnValue(true));
     if (!$realConnector) {
         $realConnector = new TestConnector();
     }
     $this->typesRegistry->expects($this->any())->method('getConnectorType')->will($this->returnValue($realConnector));
     return $integration;
 }