/** * @Transform /^rest of the world$/ * @Transform /^the rest of the world$/ */ public function getRestOfTheWorldZone() { $zone = $this->zoneRepository->findOneBy(['code' => 'RoW']); if (null === $zone) { throw new \Exception('Rest of the world zone does not exist.'); } return $zone; }
/** * @Given /^there is rest of the world zone containing all other countries$/ */ public function thereIsRestOfTheWorldZoneContainingAllOtherCountries() { $restOfWorldCountries = array_diff(array_keys(Intl::getRegionBundle()->getCountryNames('en')), array_merge($this->euMembers, ['US'])); $zone = $this->zoneFactory->createWithMembers($restOfWorldCountries); $zone->setType(ZoneInterface::TYPE_COUNTRY); $zone->setCode('RoW'); $zone->setName('Rest of the World'); $this->zoneRepository->add($zone); }
/** * @Given the store does not have any zones defined */ public function theStoreDoesNotHaveAnyZonesDefined() { $zones = $this->zoneRepository->findAll(); foreach ($zones as $zone) { $this->zoneRepository->remove($zone); } }
/** * @Given the store has a zone :zoneName with code :code * @Given the store also has a zone :zoneName with code :code */ public function theStoreHasAZoneWithCode($zoneName, $code) { $zone = $this->zoneFactory->createTyped(ZoneInterface::TYPE_ZONE); $zone->setCode($code); $zone->setName($zoneName); $this->sharedStorage->set('zone', $zone); $this->zoneRepository->add($zone); }
/** * @Given /^the store ships everywhere for free$/ */ public function theStoreShipsEverywhereForFree() { foreach ($this->zoneRepository->findAll() as $zone) { $this->createShippingMethod('Free', null, $zone); } }
/** * @param array $parameters * * @return ZoneInterface */ private function getZoneBy(array $parameters) { $existingZone = $this->zoneRepository->findOneBy($parameters); Assert::notNull($existingZone, 'Zone does not exist.'); return $existingZone; }