function it_builds_options_base_on_product_attribute(FormEvent $event, Form $form, AttributeValueInterface $productAttribute, Form $valueField, $formFactory) { $productAttribute->getType()->willReturn('choice'); $productAttribute->getConfiguration()->willReturn(array('choices' => array('red' => 'Red', 'blue' => 'Blue'))); $productAttribute->getName()->willReturn('My name'); $event->getData()->willReturn($productAttribute); $event->getForm()->willReturn($form); $formFactory->createNamed('value', 'choice', null, array('label' => 'My name', 'auto_initialize' => false, 'choices' => array('red' => 'Red', 'blue' => 'Blue')))->willReturn($valueField)->shouldBeCalled(); $form->remove('attribute')->shouldBeCalled()->willReturn($form); $form->add($valueField)->shouldBeCalled()->willReturn($form); $this->buildForm($event); }