Esempio n. 1
0
 /**
  * @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);
 }
Esempio n. 2
0
 /**
  * @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);
         }
     }
 }
Esempio n. 3
0
 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']]]]);
 }