/**
  * {@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');
     };
 }
 function it_uses_registry_to_provide_payment_methods_for_payment(PaymentMethodsResolverInterface $firstMethodsResolver, PaymentMethodsResolverInterface $secondMethodsResolver, PrioritizedServiceRegistryInterface $resolversRegistry, PaymentMethodInterface $paymentMethod, PaymentInterface $payment)
 {
     $resolversRegistry->all()->willReturn([$firstMethodsResolver, $secondMethodsResolver]);
     $firstMethodsResolver->supports($payment)->willReturn(false);
     $secondMethodsResolver->supports($payment)->willReturn(true);
     $secondMethodsResolver->getSupportedMethods($payment)->willReturn([$paymentMethod]);
     $this->getSupportedMethods($payment)->shouldReturn([$paymentMethod]);
 }