function it_does_not_support_payment_if_none_of_registered_resolvers_supports_it(PaymentMethodsResolverInterface $firstMethodsResolver, PaymentMethodsResolverInterface $secondMethodsResolver, PrioritizedServiceRegistryInterface $resolversRegistry, PaymentInterface $payment) { $resolversRegistry->all()->willReturn([$firstMethodsResolver, $secondMethodsResolver]); $firstMethodsResolver->supports($payment)->willReturn(false); $secondMethodsResolver->supports($payment)->willReturn(false); $this->supports($payment)->shouldReturn(false); }
/** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(['choices' => function (Options $options) { if (isset($options['subject'])) { return $this->paymentMethodsResolver->getSupportedMethods($options['subject']); } return $this->paymentMethodRepository->findAll(); }, 'choice_value' => 'id', 'choice_label' => 'name', 'choice_translation_domain' => false])->setDefined(['subject'])->setAllowedTypes('subject', PaymentInterface::class); }
/** * @return \Closure */ private function createChoiceList() { return function (Options $options) { if (isset($options['subject'])) { $resolvedMethods = $this->paymentMethodsResolver->getSupportedMethods($options['subject']); } else { $resolvedMethods = $this->paymentMethodRepository->findAll(); } return new ObjectChoiceList($resolvedMethods, null, [], null, 'id'); }; }