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);
 }
 function it_does_not_support_subject_if_none_of_resolvers_from_registry_supports_it(MethodsResolverInterface $firstMethodsResolver, MethodsResolverInterface $secondMethodsResolver, PrioritizedServiceRegistryInterface $resolversRegistry, ShippingSubjectInterface $shippingSubject)
 {
     $resolversRegistry->all()->willReturn([$firstMethodsResolver, $secondMethodsResolver]);
     $firstMethodsResolver->supports($shippingSubject)->willReturn(false);
     $firstMethodsResolver->supports($shippingSubject)->willReturn(false);
     $this->supports($shippingSubject)->shouldReturn(false);
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function supports(ShippingSubjectInterface $subject)
 {
     foreach ($this->resolversRegistry->all() as $resolver) {
         if ($resolver->supports($subject)) {
             return true;
         }
     }
     return false;
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function supports(PaymentInterface $payment)
 {
     foreach ($this->resolversRegistry->all() as $resolver) {
         if ($resolver->supports($payment)) {
             return true;
         }
     }
     return false;
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function process(OrderInterface $order)
 {
     $this->clearTaxes($order);
     if ($order->isEmpty()) {
         return;
     }
     $zone = $this->getTaxZone($order);
     if (null === $zone) {
         return;
     }
     /** @var TaxCalculationStrategyInterface $strategy */
     foreach ($this->strategyRegistry->all() as $strategy) {
         if ($strategy->supports($order, $zone)) {
             $strategy->applyTaxes($order, $zone);
             return;
         }
     }
     throw new UnsupportedTaxCalculationStrategyException();
 }
Пример #6
0
 function it_does_not_process_taxes_if_there_is_no_tax_zone(ZoneProviderInterface $defaultTaxZoneProvider, ZoneMatcherInterface $zoneMatcher, PrioritizedServiceRegistryInterface $strategyRegistry, OrderInterface $order, OrderItemInterface $orderItem, AddressInterface $address)
 {
     $order->getItems()->willReturn([$orderItem]);
     $order->isEmpty()->willReturn(false);
     $order->removeAdjustments(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled();
     $orderItem->removeAdjustmentsRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled();
     $order->getShippingAddress()->willReturn($address);
     $zoneMatcher->match($address)->willReturn(null);
     $defaultTaxZoneProvider->getZone($order)->willReturn(null);
     $strategyRegistry->all()->shouldNotBeCalled();
     $this->process($order);
 }
 function it_does_not_process_taxes_if_there_is_no_tax_zone(ZoneProviderInterface $defaultTaxZoneProvider, ZoneMatcherInterface $zoneMatcher, AddressInterface $address, \Iterator $itemsIterator, Collection $items, OrderInterface $order, OrderItemInterface $orderItem, PrioritizedServiceRegistryInterface $strategyRegistry)
 {
     $order->removeAdjustments(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled();
     $order->getItems()->willReturn($items);
     $order->isEmpty()->willReturn(false);
     $items->count()->willReturn(1);
     $items->getIterator()->willReturn($itemsIterator);
     $itemsIterator->rewind()->shouldBeCalled();
     $itemsIterator->valid()->willReturn(true, false)->shouldBeCalled();
     $itemsIterator->current()->willReturn($orderItem);
     $itemsIterator->next()->shouldBeCalled();
     $orderItem->removeAdjustmentsRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled();
     $order->getShippingAddress()->willReturn($address);
     $zoneMatcher->match($address)->willReturn(null);
     $defaultTaxZoneProvider->getZone($order)->willReturn(null);
     $strategyRegistry->all()->shouldNotBeCalled();
     $this->process($order);
 }