/**
  * @dataProvider getCompoundOptionTests
  */
 public function testCompoundOption($expectedCompound, $multiple, $expanded)
 {
     $type = new ModelType();
     $modelManager = $this->getMock('Sonata\\AdminBundle\\Model\\ModelManagerInterface');
     $optionResolver = new OptionsResolver();
     if (!method_exists('Symfony\\Component\\Form\\AbstractType', 'getBlockPrefix')) {
         $type->setDefaultOptions($optionResolver);
     } else {
         $type->configureOptions($optionResolver);
     }
     $options = $optionResolver->resolve(array('model_manager' => $modelManager, 'choices' => array(), 'multiple' => $multiple, 'expanded' => $expanded));
     $this->assertSame($expectedCompound, $options['compound']);
     $this->assertSame('choice', $options['template']);
     $this->assertSame($multiple, $options['multiple']);
     $this->assertSame($expanded, $options['expanded']);
     $this->assertInstanceOf('Sonata\\AdminBundle\\Model\\ModelManagerInterface', $options['model_manager']);
     $this->assertNull($options['class']);
     $this->assertNull($options['property']);
     $this->assertNull($options['query']);
     $this->assertSame(0, count($options['choices']));
     $this->assertSame(0, count($options['preferred_choices']));
     $this->assertSame('link_add', $options['btn_add']);
     $this->assertSame('link_list', $options['btn_list']);
     $this->assertSame('link_delete', $options['btn_delete']);
     $this->assertSame('SonataAdminBundle', $options['btn_catalogue']);
     if (interface_exists('Symfony\\Component\\Form\\ChoiceList\\Loader\\ChoiceLoaderInterface')) {
         // SF2.7+
         $this->assertInstanceOf('Sonata\\AdminBundle\\Form\\ChoiceList\\ModelChoiceLoader', $options['choice_loader']);
     } else {
         $this->assertInstanceOf('Sonata\\AdminBundle\\Form\\ChoiceList\\ModelChoiceList', $options['choice_list']);
     }
 }
예제 #2
0
 /**
  * @dataProvider getCompoundOptionTests
  */
 public function testCompoundOption($expectedCompound, $multiple, $expanded)
 {
     $type = new ModelType();
     $modelManager = $this->getMock('Sonata\\AdminBundle\\Model\\ModelManagerInterface');
     $optionResolver = new OptionsResolver();
     $type->setDefaultOptions($optionResolver);
     $options = $optionResolver->resolve(array('model_manager' => $modelManager, 'choices' => array(), 'multiple' => $multiple, 'expanded' => $expanded));
     $this->assertEquals($expectedCompound, $options['compound']);
     $this->assertEquals('choice', $options['template']);
     $this->assertEquals($multiple, $options['multiple']);
     $this->assertEquals($expanded, $options['expanded']);
     $this->assertInstanceOf('Sonata\\AdminBundle\\Model\\ModelManagerInterface', $options['model_manager']);
     $this->assertNull($options['class']);
     $this->assertNull($options['property']);
     $this->assertNull($options['query']);
     $this->assertEquals(0, count($options['choices']));
     $this->assertEquals(0, count($options['preferred_choices']));
     $this->assertEquals('link_add', $options['btn_add']);
     $this->assertEquals('link_list', $options['btn_list']);
     $this->assertEquals('link_delete', $options['btn_delete']);
     $this->assertEquals('SonataAdminBundle', $options['btn_catalogue']);
     $this->assertInstanceOf('Sonata\\AdminBundle\\Form\\ChoiceList\\ModelChoiceList', $options['choice_list']);
 }
예제 #3
0
 /**
  * {@inheritDoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     parent::setDefaultOptions($resolver);
     $resolver->setDefaults(['model_manager' => $this->mm]);
 }