/**
  * {@inheritdoc}
  */
 public function getSupportedMethods(ShippingSubjectInterface $subject)
 {
     /** @var ShipmentInterface $subject */
     Assert::true($this->supports($subject));
     /** @var OrderInterface $order */
     $order = $subject->getOrder();
     $zones = $this->zoneMatcher->matchAll($order->getShippingAddress());
     if (empty($zones)) {
         return [];
     }
     return $this->shippingMethodRepository->findEnabledForZonesAndChannel($zones, $order->getChannel());
 }
 function it_returns_shipping_methods_matched_for_shipment_order_shipping_address_and_order_channel(AddressInterface $address, ChannelInterface $channel, OrderInterface $order, ShipmentInterface $shipment, ShippingMethodInterface $firstShippingMethod, ShippingMethodInterface $secondShippingMethod, ShippingMethodRepositoryInterface $shippingMethodRepository, ZoneInterface $firstZone, ZoneInterface $secondZone, ZoneMatcherInterface $zoneMatcher)
 {
     $shipment->getOrder()->willReturn($order);
     $order->getShippingAddress()->willReturn($address);
     $order->getChannel()->willReturn($channel);
     $zoneMatcher->matchAll($address)->willReturn([$firstZone, $secondZone]);
     $shippingMethodRepository->findEnabledForZonesAndChannel([$firstZone, $secondZone], $channel)->willReturn([$firstShippingMethod, $secondShippingMethod]);
     $this->getSupportedMethods($shipment)->shouldReturn([$firstShippingMethod, $secondShippingMethod]);
 }
 /**
  * {@inheritdoc}
  */
 public function getSupportedMethods(ShippingSubjectInterface $subject)
 {
     /** @var ShipmentInterface $subject */
     Assert::true($this->supports($subject));
     /** @var OrderInterface $order */
     $order = $subject->getOrder();
     $zones = $this->zoneMatcher->matchAll($order->getShippingAddress());
     if (empty($zones)) {
         return [];
     }
     $methods = [];
     $shippingMethods = $this->shippingMethodRepository->findEnabledForZonesAndChannel($zones, $order->getChannel());
     foreach ($shippingMethods as $shippingMethod) {
         if ($this->eligibilityChecker->isEligible($subject, $shippingMethod)) {
             $methods[] = $shippingMethod;
         }
     }
     return $methods;
 }
 function it_returns_only_shipping_methods_that_are_eligible(ShippingMethodEligibilityCheckerInterface $eligibilityChecker, AddressInterface $address, ChannelInterface $channel, OrderInterface $order, ShipmentInterface $shipment, ShippingMethodInterface $firstShippingMethod, ShippingMethodInterface $secondShippingMethod, ShippingMethodRepositoryInterface $shippingMethodRepository, ZoneInterface $firstZone, ZoneInterface $secondZone, ZoneMatcherInterface $zoneMatcher)
 {
     $shipment->getOrder()->willReturn($order);
     $order->getShippingAddress()->willReturn($address);
     $order->getChannel()->willReturn($channel);
     $zoneMatcher->matchAll($address)->willReturn([$firstZone, $secondZone]);
     $eligibilityChecker->isEligible($shipment, $firstShippingMethod)->willReturn(false);
     $eligibilityChecker->isEligible($shipment, $secondShippingMethod)->willReturn(true);
     $shippingMethodRepository->findEnabledForZonesAndChannel([$firstZone, $secondZone], $channel)->willReturn([$firstShippingMethod, $secondShippingMethod]);
     $this->getSupportedMethods($shipment)->shouldReturn([$secondShippingMethod]);
 }