Elcodi\Plugin\CustomShippingBundle\Tests\UnitTest\Provider\ShippingRangesProviderTest::getBuiltCarrierRepository PHP Method

getBuiltCarrierRepository() private method

Get functional carrier
private getBuiltCarrierRepository ( $withCarrier, $priceFrom = null, $priceTo = null, $priceRangePrice, $weightFrom = null, $weightTo = null, $weightRangePrice )
    private function getBuiltCarrierRepository($withCarrier, $priceFrom = null, $priceTo = null, $priceRangePrice = 0, $weightFrom = null, $weightTo = null, $weightRangePrice = 0)
    {
        $carriers = [];
        $carrier = $this->getCarrier();
        if ($withCarrier) {
            $shippingRanges = [];
            $currency = $this->getCurrency();
            if ($priceFrom || $priceTo) {
                $priceShippingRange = $this->getShippingRange();
                $priceShippingRange->getFromPrice()->willReturn(Money::create($priceFrom, $currency));
                $priceShippingRange->getToPrice()->willReturn(Money::create($priceTo, $currency));
                $priceShippingRange->getPrice()->willReturn(Money::create($priceRangePrice, $currency));
                $priceShippingRange->getType()->willReturn(ElcodiShippingRangeTypes::TYPE_PRICE);
                $priceShippingRange->getName()->willReturn('price-shipping-range-name');
                $priceShippingRange->getId()->willReturn('price-shipping-range-id');
                $priceShippingRange->getToZone()->willReturn($this->prophesize('Elcodi\\Component\\Zone\\Entity\\Interfaces\\ZoneInterface')->reveal());
                $priceShippingRange->getCarrier()->willReturn($carrier);
                $shippingRanges[] = $priceShippingRange->reveal();
            }
            if ($weightFrom || $weightTo) {
                $weightShippingRange = $this->getShippingRange();
                $weightShippingRange->getFromWeight()->willReturn($weightFrom);
                $weightShippingRange->getToWeight()->willReturn($weightTo);
                $weightShippingRange->getPrice()->willReturn(Money::create($weightRangePrice, $currency));
                $weightShippingRange->getType()->willReturn(ElcodiShippingRangeTypes::TYPE_WEIGHT);
                $weightShippingRange->getName()->willReturn('weight-shipping-range-name');
                $weightShippingRange->getId()->willReturn('weight-shipping-range-id');
                $weightShippingRange->getToZone()->willReturn($this->prophesize('Elcodi\\Component\\Zone\\Entity\\Interfaces\\ZoneInterface')->reveal());
                $weightShippingRange->getCarrier()->willReturn($carrier);
                $shippingRanges[] = $weightShippingRange->reveal();
            }
            $carrier->getRanges()->willReturn(new ArrayCollection($shippingRanges));
            $carriers = [$carrier];
        }
        $carrierRepository = $this->getCarrierRepository();
        $carrierRepository->findBy(Argument::type('array'))->willReturn($carriers);
        return $carrierRepository;
    }