コード例 #1
0
 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);
 }
コード例 #2
0
 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);
 }