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);
 }
 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);
 }
Esempio n. 3
0
 /**
  * @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);
 }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
 /**
  * @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);
 }
Esempio n. 6
0
 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();
 }
 /**
  * @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()));
 }
Esempio n. 8
0
 function it_matches_all_zones_with_given_address(RepositoryInterface $repository, AddressInterface $address, ZoneMemberInterface $memberProvince, ZoneMemberInterface $memberCountry, ZoneMemberInterface $memberZone, ZoneInterface $zoneProvince, ZoneInterface $zoneCountry, ZoneInterface $zoneZone)
 {
     $repository->findAll()->willReturn([$zoneProvince, $zoneCountry, $zoneZone]);
     $address->getProvinceCode()->willReturn('TX');
     $memberProvince->getCode()->willReturn('TX');
     $memberProvince->getBelongsTo()->willReturn($zoneProvince);
     $zoneProvince->getType()->willReturn(ZoneInterface::TYPE_PROVINCE);
     $zoneProvince->getMembers()->willReturn([$memberProvince]);
     $address->getCountryCode()->willReturn('US');
     $memberCountry->getCode()->willReturn('US');
     $zoneCountry->getType()->willReturn(ZoneInterface::TYPE_COUNTRY);
     $zoneCountry->getMembers()->willReturn([$memberCountry]);
     $zoneCountry->getCode()->willReturn('USA');
     $memberCountry->getBelongsTo()->willReturn($zoneCountry);
     $memberZone->getCode()->willReturn('USA');
     $zoneZone->getType()->willReturn(ZoneInterface::TYPE_ZONE);
     $zoneZone->getMembers()->willReturn([$memberZone]);
     $memberZone->getBelongsTo()->willReturn($zoneZone);
     $repository->findOneBy(['code' => 'USA'])->willReturn($zoneCountry);
     $this->matchAll($address)->shouldReturn([$zoneProvince, $zoneCountry, $zoneZone]);
 }