function it_does_not_build_choices_collection_for_other_than_choice_attribute_types(FormEvent $event, Form $form, AttributeInterface $attribute, Form $collectionField, $formFactory)
 {
     $attribute->getType()->willReturn(AttributeTypes::TEXT);
     $event->getData()->willReturn($attribute);
     $event->getForm()->willReturn($form);
     $formFactory->createNamed('choices', 'collection', null, Argument::any())->willReturn($collectionField)->shouldNotBeCalled();
     $form->add(Argument::any())->shouldNotBeCalled();
     $this->buildChoices($event);
 }
Esempio n. 2
0
 function it_creates_new_values_only_for_non_existing_attributes($attributeValueFactory, ArchetypeInterface $archetype, ArchetypeSubjectInterface $subject, AttributeInterface $attribute, AttributeValueInterface $attributeValue, OptionInterface $option)
 {
     $archetype->getAttributes()->willReturn(array($attribute))->shouldBeCalled();
     $archetype->getOptions()->willReturn(array($option))->shouldBeCalled();
     $attribute->getCode()->willReturn('test');
     $subject->getAttributeByCode('test')->shouldBeCalled()->willReturn($attributeValue);
     $attributeValueFactory->createNew()->shouldNotBeCalled();
     $attributeValue->setAttribute($attribute)->shouldNotBeCalled();
     $subject->getArchetype()->willReturn($archetype);
     $subject->addAttribute(Argument::any())->shouldNotBeCalled();
     $subject->addOption($option)->shouldBeCalled();
     $this->build($subject);
 }
Esempio n. 3
0
 function it_builds_attribute_types_prototype_and_passes_it_as_argument(FormBuilder $builder, FormBuilder $fieldBuilder, FormFactoryInterface $formFactory, ChoiceListInterface $choiceList, AttributeInterface $attribute)
 {
     $builder->getFormFactory()->willReturn($formFactory);
     $builder->add('attribute', 'sylius_server_attribute_choice', Argument::any())->willReturn($builder);
     $builder->addEventSubscriber(Argument::any())->willReturn($builder);
     $attribute->getType()->willReturn('checkbox')->shouldBeCalled();
     $attribute->getConfiguration()->willReturn(array('label' => 'sylius.form.attribute.server_attribute_value.value'))->shouldBeCalled();
     $choiceList->getChoices()->willReturn(array($attribute));
     $fieldBuilder->getOption('choice_list')->willReturn($choiceList);
     $builder->get('attribute')->willReturn($fieldBuilder);
     $builder->create('value', 'checkbox', array('label' => 'sylius.form.attribute.server_attribute_value.value'))->shouldBeCalled()->willReturn($fieldBuilder);
     $fieldBuilder->getForm()->willReturn('Form for attribute');
     $builder->setAttribute('prototypes', array(0 => 'Form for attribute'))->shouldBeCalled();
     $this->buildForm($builder, array());
 }
Esempio n. 4
0
 /**
  * @param FormInterface $form
  * @param AttributeInterface $attribute
  */
 protected function addValueField(FormInterface $form, AttributeInterface $attribute)
 {
     $form->add('value', $this->formTypeRegistry->get($attribute->getType(), 'default'), ['auto_initialize' => false, 'label' => $attribute->getName()]);
 }
 /**
  * @param FormInterface $form
  * @param AttributeInterface $attribute
  */
 private function addValueField(FormInterface $form, AttributeInterface $attribute)
 {
     $options = array('auto_initialize' => false, 'label' => $attribute->getName());
     $form->add('value', 'sylius_attribute_type_' . $attribute->getType(), $options);
 }
Esempio n. 6
0
 function it_returns_its_attribute_type(AttributeInterface $attribute)
 {
     $attribute->getType()->willReturn('choice');
     $this->setAttribute($attribute);
     $this->getType()->shouldReturn('choice');
 }
 /**
  * @param AttributeInterface $attribute
  *
  * @return FormView
  */
 private function getAttributeForm(AttributeInterface $attribute)
 {
     $attributeForm = 'sylius_attribute_type_' . $attribute->getType();
     $form = $this->get('form.factory')->createNamed('value', $attributeForm, null, ['label' => $attribute->getName()]);
     return $form->createView();
 }
 /**
  * @param AttributeInterface $attribute
  *
  * @return FormView
  */
 protected function getAttributeForm(AttributeInterface $attribute)
 {
     $attributeForm = $this->get('sylius.form_registry.attribute_type')->get($attribute->getType(), 'default');
     $form = $this->get('form.factory')->createNamed('value', $attributeForm, null, ['label' => $attribute->getName()]);
     return $form->createView();
 }
Esempio n. 9
0
 function it_returns_its_attribute_configuration(AttributeInterface $attribute)
 {
     $attribute->getConfiguration()->willReturn(array('choices' => array('Red')));
     $this->setAttribute($attribute);
     $this->getConfiguration()->shouldReturn(array('choices' => array('Red')));
 }