/** * @Given /^there is "EU" zone containing all members of European Union$/ */ public function thereIsEUZoneContainingAllMembersOfEuropeanUnion() { $zone = $this->zoneFactory->createWithMembers($this->euMembers); $zone->setType(ZoneInterface::TYPE_COUNTRY); $zone->setCode('EU'); $zone->setName('European Union'); $this->zoneRepository->add($zone); }
/** * @Given /^there is a zone "The Rest of the World" containing all other countries$/ */ public function thereIsAZoneTheRestOfTheWorldContainingAllOtherCountries() { $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('The Rest of the World'); $this->zoneRepository->add($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); }
/** * @param array $zones * @param \Closure $zoneValidator */ private function loadZones(array $zones, \Closure $zoneValidator) { foreach ($zones as $zoneCode => $zoneOptions) { $zoneName = $zoneOptions['name']; try { $zoneValidator($zoneOptions); $zoneType = $this->getZoneType($zoneOptions); $zoneMembers = $this->getZoneMembers($zoneOptions); /** @var ZoneInterface $zone */ $zone = $this->zoneFactory->createWithMembers($zoneMembers); $zone->setCode($zoneCode); $zone->setName($zoneName); $zone->setType($zoneType); $this->zoneManager->persist($zone); } catch (\InvalidArgumentException $exception) { throw new \InvalidArgumentException(sprintf('An exception was thrown during loading zone "%s" with code "%s"!', $zoneName, $zoneCode), 0, $exception); } } }
function it_creates_and_persist_a_country_type_zone_and_a_zone_containing_it(FactoryInterface $countryFactory, ObjectManager $countryManager, ZoneFactoryInterface $zoneFactory, ObjectManager $zoneManager, CountryInterface $country, ZoneInterface $countryTypeZone, ZoneInterface $zoneTypeZone) { $countryFactory->createNew()->willReturn($country); $country->setCode('PL')->shouldBeCalled(); $country->enable()->shouldBeCalled(); $zoneFactory->createWithMembers(['PL'])->willReturn($countryTypeZone); $countryTypeZone->setCode('POLAND')->shouldBeCalled(); $countryTypeZone->setName('Poland')->shouldBeCalled(); $countryTypeZone->setType(ZoneInterface::TYPE_COUNTRY)->shouldBeCalled(); $zoneFactory->createWithMembers(['POLAND'])->willReturn($zoneTypeZone); $zoneTypeZone->setCode('YO-DAWG')->shouldBeCalled(); $zoneTypeZone->setName('Yo dawg')->shouldBeCalled(); $zoneTypeZone->setType(ZoneInterface::TYPE_ZONE)->shouldBeCalled(); $countryManager->persist($country)->shouldBeCalled(); $zoneManager->persist($countryTypeZone)->shouldBeCalled(); $zoneManager->persist($zoneTypeZone)->shouldBeCalled(); $countryManager->flush()->shouldBeCalled(); $zoneManager->flush()->shouldBeCalled(); $this->load(['countries' => ['PL'], 'provinces' => [], 'zones' => ['POLAND' => ['name' => 'Poland', 'countries' => ['PL'], 'provinces' => [], 'zones' => []], 'YO-DAWG' => ['name' => 'Yo dawg', 'countries' => [], 'provinces' => [], 'zones' => ['POLAND']]]]); }