Esempio n. 1
0
 function it_builds_prototypes_forms_for_calculators(ServiceRegistryInterface $calculatorRegistry, FormBuilder $builder, FormBuilder $flatRateFormBuilder, Form $flatRateForm, CalculatorInterface $flatRateCalculator, FormBuilder $perUnitFormBuilder, Form $perUnitForm, CalculatorInterface $perUnitRateCalculator, FormRegistryInterface $formRegistry)
 {
     $builder->add(Argument::any(), Argument::cetera())->willReturn($builder);
     $builder->addEventSubscriber(Argument::any())->willReturn($builder);
     $flatRateCalculator->getType()->willReturn('flat_rate');
     $perUnitRateCalculator->getType()->willReturn('per_unit_rate');
     $calculatorRegistry->all()->willReturn(['flat_rate' => $flatRateCalculator, 'per_unit_rate' => $perUnitRateCalculator]);
     $flatRateFormBuilder->getForm()->willReturn($flatRateForm);
     $builder->create('configuration', 'sylius_shipping_calculator_flat_rate')->willReturn($flatRateFormBuilder);
     $perUnitFormBuilder->getForm()->willReturn($perUnitForm);
     $builder->create('configuration', 'sylius_shipping_calculator_per_unit_rate')->willReturn($perUnitFormBuilder);
     $formRegistry->hasType('sylius_shipping_calculator_per_unit_rate')->shouldBeCalled()->willReturn(true);
     $formRegistry->hasType('sylius_shipping_calculator_flat_rate')->shouldBeCalled()->willReturn(true);
     $builder->setAttribute('prototypes', ['calculators' => ['flat_rate' => $flatRateForm, 'per_unit_rate' => $perUnitForm], 'rules' => []])->shouldBeCalled();
     $this->buildForm($builder, []);
 }
Esempio n. 2
0
 function it_returns_per_unit_rate_type(CalculatorInterface $calculator)
 {
     $calculator->getType()->willReturn('per_unit_rate');
     $this->getType()->shouldReturn('per_unit_rate');
 }