function it_builds_form(ServiceRegistryInterface $calculatorRegistry, EventSubscriberInterface $subscriber, FormBuilderInterface $builder, CalculatorInterface $calculator, FormBuilderInterface $formBuilder, FormInterface $form) { $builder->addEventSubscriber($subscriber)->shouldBeCalled()->willreturn($builder); $builder->add('pricingCalculator', 'sylius_price_calculator_choice', Argument::type('array'))->shouldBeCalled(); $calculatorRegistry->all()->shouldBeCalled()->willReturn(['type' => $calculator]); $calculator->getType()->shouldBeCalled()->willReturn('standard'); $builder->create('pricingConfiguration', 'sylius_price_calculator_standard')->shouldBeCalled()->willReturn($formBuilder); $formBuilder->getForm()->shouldBeCalled()->willReturn($form); $builder->setAttribute('prototypes', ['type' => $form])->shouldBeCalled(); $this->buildForm($builder, []); }
function it_should_add_configuration_fields_in_pre_set_data($calculatorRegistry, CalculatorInterface $calculator, $factory, FormEvent $event, PriceableInterface $priceable, Form $form, Form $field) { $event->getData()->shouldBeCalled()->willReturn($priceable); $event->getForm()->shouldBeCalled()->willReturn($form); $calculator->getType()->shouldBeCalled()->willReturn('foo'); $calculatorRegistry->get('bar')->shouldBeCalled()->willReturn($calculator); $priceable->getPricingCalculator()->shouldBeCalled()->willReturn('bar'); $priceable->getPricingConfiguration()->shouldBeCalled()->willReturn(array()); $factory->createNamed('pricingConfiguration', 'sylius_price_calculator_foo', array(), Argument::any())->shouldBeCalled()->willReturn($field); $form->add($field)->shouldBeCalled(); $this->preSetData($event); }