function it_configures_options(OptionsResolver $resolver, ZoneInterface $zone, RepositoryInterface $repository) { $zone->getCode()->willReturn('EU'); $zone->getName()->willReturn('European Union'); $repository->findAll()->willReturn(array($zone)); $resolver->setDefaults(array('choices' => array('EU' => 'European Union'), 'label' => 'sylius.form.zone.types.zone', 'empty_value' => 'sylius.form.zone.select'))->willReturn($resolver); $this->configureOptions($resolver); }
function it_configures_options(OptionsResolver $resolver, ZoneInterface $zone, RepositoryInterface $repository) { $zone->getCode()->willReturn('EU'); $zone->getName()->willReturn('European Union'); $repository->findAll()->willReturn([$zone]); $resolver->setDefaults(['choice_translation_domain' => false, 'choices' => ['EU' => 'European Union'], 'label' => 'sylius.form.zone.types.zone', 'empty_value' => 'sylius.form.zone.select'])->willReturn($resolver); $this->configureOptions($resolver); }
/** * @param AddressInterface $address * @param ZoneInterface $zone * * @return bool */ protected function addressBelongsToZone(AddressInterface $address, ZoneInterface $zone) { foreach ($zone->getMembers() as $member) { if ($this->addressBelongsToZoneMember($address, $member)) { return true; } } return false; }
/** * @Given the store has :taxRateName tax rate of :taxRateAmount% for :taxCategoryName within :zone zone * @Given /^the store has "([^"]+)" tax rate of ([^"]+)% for "([^"]+)" for (the rest of the world)$/ */ public function storeHasTaxRateWithinZone($taxRateName, $taxRateAmount, $taxCategoryName, ZoneInterface $zone) { $taxCategory = $this->getOrCreateTaxCategory($taxCategoryName); $taxRate = $this->taxRateFactory->createNew(); $taxRate->setName($taxRateName); $taxRate->setCode($this->getCodeFromNameAndZoneCode($taxRateName, $zone->getCode())); $taxRate->setZone($zone); $taxRate->setAmount($this->getAmountFromString($taxRateAmount)); $taxRate->setCategory($taxCategory); $taxRate->setCalculator('default'); $this->taxRateRepository->add($taxRate); }
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, ShippingMethodInterface $thirdShippingMethod, 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]); $firstZone->getId()->willReturn(1); $secondZone->getId()->willReturn(4); $shippingMethodRepository->findBy(['enabled' => true, 'zone' => [1, 4]])->willReturn([$firstShippingMethod, $secondShippingMethod, $thirdShippingMethod]); $channel->hasShippingMethod($firstShippingMethod)->willReturn(true); $channel->hasShippingMethod($secondShippingMethod)->willReturn(true); $channel->hasShippingMethod($thirdShippingMethod)->willReturn(false); $this->getSupportedMethods($shipment)->shouldReturn([$firstShippingMethod, $secondShippingMethod]); }
function it_creates_tax_rate_for_given_tax_category_and_zone($taxRateFactory, $taxCategoryFactory, $taxRateRepository, $taxCategoryRepository, TaxCategoryInterface $taxCategory, TaxRateInterface $taxRate, ZoneInterface $zone) { $taxCategoryRepository->findOneBy(['name' => 'Clothes'])->willReturn(null); $taxCategoryFactory->createNew()->willReturn($taxCategory); $taxCategory->setName('Clothes')->shouldBeCalled(); $taxCategory->setCode('clothes')->shouldBeCalled(); $taxCategoryRepository->add($taxCategory)->shouldBeCalled(); $zone->getCode()->willReturn('EU'); $taxRateFactory->createNew()->willReturn($taxRate); $taxRate->setName('Low VAT')->shouldBeCalled(); $taxRate->setCode('low_vat_eu')->shouldBeCalled(); $taxRate->setAmount(0.23)->shouldBeCalled(); $taxRate->setCategory($taxCategory)->shouldBeCalled(); $taxRate->setZone($zone)->shouldBeCalled(); $taxRate->setCalculator('default')->shouldBeCalled(); $taxRateRepository->add($taxRate)->shouldBeCalled(); $this->storeHasTaxRateWithinZone('Low VAT', '23%', 'Clothes', $zone); }
/** * @Given the store has :taxRateName tax rate of :taxRateAmount% for :taxCategoryName within :zone zone * @Given the store has :taxRateName tax rate of :taxRateAmount% for :taxCategoryName within :zone zone identified by :taxRateCode code * @Given /^the store has "([^"]+)" tax rate of ([^"]+)% for "([^"]+)" for (the rest of the world)$/ */ public function storeHasTaxRateWithinZone($taxRateName, $taxRateAmount, $taxCategoryName, ZoneInterface $zone, $taxRateCode = null, $includedInPrice = false) { $taxCategory = $this->getOrCreateTaxCategory($taxCategoryName); if (null === $taxRateCode) { $taxRateCode = $this->getCodeFromNameAndZoneCode($taxRateName, $zone->getCode()); } /** @var TaxRateInterface $taxRate */ $taxRate = $this->taxRateFactory->createNew(); $taxRate->setName($taxRateName); $taxRate->setCode($taxRateCode); $taxRate->setZone($zone); $taxRate->setAmount($this->getAmountFromString($taxRateAmount)); $taxRate->setCategory($taxCategory); $taxRate->setCalculator('default'); $taxRate->setIncludedInPrice($includedInPrice); $this->taxRateRepository->add($taxRate); $this->sharedStorage->set('tax_rate', $taxRate); }
function it_configures_store_to_ship_everything_for_free_in_every_available_zone($shippingMethodRepository, $zoneRepository, $shippingMethodFactory, ShippingMethod $euShippingMethod, ShippingMethod $usShippingMethod, ZoneInterface $euZone, ZoneInterface $usZone) { $zoneRepository->findAll()->willReturn([$euZone, $usZone]); $shippingMethodFactory->createNew()->willReturn($euShippingMethod, $usShippingMethod); $euZone->getCode()->willReturn('UE'); $euShippingMethod->setCode('free_ue')->shouldBeCalled(); $euShippingMethod->setName('Free')->shouldBeCalled(); $euShippingMethod->setCurrentLocale('en')->shouldBeCalled(); $euShippingMethod->setConfiguration(['amount' => 0])->shouldBeCalled(); $euShippingMethod->setCalculator(DefaultCalculators::FLAT_RATE)->shouldBeCalled(); $euShippingMethod->setZone($euZone)->shouldBeCalled(); $usZone->getCode()->willReturn('US'); $usShippingMethod->setCode('free_us')->shouldBeCalled(); $usShippingMethod->setName('Free')->shouldBeCalled(); $usShippingMethod->setCurrentLocale('en')->shouldBeCalled(); $usShippingMethod->setConfiguration(['amount' => 0])->shouldBeCalled(); $usShippingMethod->setCalculator(DefaultCalculators::FLAT_RATE)->shouldBeCalled(); $usShippingMethod->setZone($usZone)->shouldBeCalled(); $shippingMethodRepository->add($euShippingMethod)->shouldBeCalled(); $shippingMethodRepository->add($usShippingMethod)->shouldBeCalled(); $this->theStoreShipsEverythingForFreeToAllAvailableLocations(); }
/** * @Given /^(it) has the (zone named "([^"]+)")$/ * @Given /^(it) also has the (zone named "([^"]+)")$/ */ public function itHasTheZoneMemberAndTheZoneMember(ZoneInterface $parentZone, ZoneInterface $childZone) { $parentZone->setType(ZoneInterface::TYPE_ZONE); $parentZone->addMember($this->createZoneMember($childZone)); $this->objectManager->flush(); }
function it_returns_zone_name(ZoneInterface $zone) { $zone->getName()->willReturn('USA'); $this->setZone($zone); $this->getName()->shouldReturn('USA'); }
/** * @param ZoneInterface $zone * @param ZoneMemberInterface $zoneMember * * @throws \InvalidArgumentException */ private function assertZoneAndItsMember(ZoneInterface $zone, ZoneMemberInterface $zoneMember) { Assert::true($this->updatePage->hasResourceValues(['code' => $zone->getCode(), 'name' => $zone->getName()]), sprintf('Zone %s is not valid', $zone->getName())); Assert::true($this->updatePage->hasMember($zoneMember), sprintf('Zone %s has not %s zone member', $zone->getName(), $zoneMember->getCode())); }
function it_matches_all_zones_by_scope_when_one_zone_for_address_is_defined(RepositoryInterface $repository, AddressInterface $address, ZoneMemberInterface $memberCountry, ZoneInterface $zoneCountry) { $repository->findBy(['scope' => 'shipping'])->willReturn([$zoneCountry]); $address->getCountryCode()->willReturn('US'); $memberCountry->getCode()->willReturn('US'); $zoneCountry->getType()->willReturn(ZoneInterface::TYPE_COUNTRY); $zoneCountry->getMembers()->willReturn([$memberCountry]); $memberCountry->getBelongsTo()->willReturn($zoneCountry); $this->matchAll($address, 'shipping')->shouldReturn([$zoneCountry]); }
function it_should_match_all_zones_by_scope_when_one_zone_for_address_is_defined($repository, CountryInterface $country, AddressInterface $address, ZoneMemberCountry $memberCountry, ZoneInterface $zoneCountry) { $repository->findBy(array('scope' => 'shipping'))->shouldBeCalled()->willReturn(array($zoneCountry)); $address->getCountry()->shouldBeCalled()->willReturn($country); $memberCountry->getCountry()->shouldBeCalled()->willReturn($country); $zoneCountry->getType()->shouldBeCalled()->willReturn(ZoneInterface::TYPE_COUNTRY); $zoneCountry->getMembers()->shouldBeCalled()->willReturn(array($memberCountry)); $memberCountry->getBelongsTo()->willReturn($zoneCountry); $this->matchAll($address, 'shipping')->shouldReturn(array($zoneCountry)); }