Exemplo n.º 1
0
 /**
  * @param string $name
  */
 private function createCountryNamed($name)
 {
     /** @var CountryInterface $country */
     $country = $this->countryFactory->createNew();
     $country->setCode($this->countryNameConverter->convertToCode($name));
     $this->countryRepository->add($country);
 }
Exemplo n.º 2
0
 /**
  * @Transform /^country "([^"]+)"$/
  * @Transform /^"([^"]+)" country$/
  * @Transform /^"([^"]+)" as shipping country$/
  */
 public function getCountryByName($countryName)
 {
     $countryCode = $this->countryNameConverter->convertToCode($countryName);
     $country = $this->countryRepository->findOneBy(['code' => $countryCode]);
     Assert::notNull($country, sprintf('Country with name "%s" does not exist', $countryName));
     return $country;
 }
Exemplo n.º 3
0
 /**
  * @Transform /^country "([^"]+)"$/
  * @Transform /^"([^"]+)" country$/
  */
 public function getCountryByName($countryName)
 {
     $countryCode = $this->countryNameConverter->convertToCode($countryName);
     $country = $this->countryRepository->findOneBy(['code' => $countryCode]);
     if (null === $country) {
         throw new \InvalidArgumentException(sprintf('Country with name %s does not exist', $countryName));
     }
     return $country;
 }
Exemplo n.º 4
0
 function it_configures_that_store_operates_in_given_country_disabled_by_default(CountryInterface $country, CountryNameConverterInterface $nameToCodeConverter, FactoryInterface $countryFactory, RepositoryInterface $countryRepository, SharedStorageInterface $sharedStorage)
 {
     $countryFactory->createNew()->willReturn($country);
     $nameToCodeConverter->convertToCode('France')->willReturn('FR');
     $country->setCode('FR')->shouldBeCalled();
     $country->disable()->shouldBeCalled();
     $sharedStorage->set('country', $country)->shouldBeCalled();
     $countryRepository->add($country)->shouldBeCalled();
     $this->theStoreHasDisabledCountry('France');
 }
 function it_creates_new_address_based_on_given_country(AddressInterface $address, FactoryInterface $addressFactory, CountryNameConverterInterface $countryNameConverter)
 {
     $countryNameConverter->convertToCode('France')->willReturn('FR');
     $addressFactory->createNew()->willReturn($address);
     $address->setCountryCode('FR')->shouldBeCalled();
     $address->setFirstName('John')->shouldBeCalled();
     $address->setLastName('Doe')->shouldBeCalled();
     $address->setCity('Ankh Morpork')->shouldBeCalled();
     $address->setStreet('Frost Alley')->shouldBeCalled();
     $address->setPostcode('90210')->shouldBeCalled();
     $this->createNewAddress('France')->shouldReturn($address);
 }
Exemplo n.º 6
0
 function it_configures_shipping_destination_countries(FactoryInterface $countryFactory, RepositoryInterface $countryRepository, CountryInterface $australia, CountryInterface $china, CountryInterface $france, CountryNameConverterInterface $nameToCodeConverter)
 {
     $countryFactory->createNew()->willReturn($australia, $china, $france);
     $australia->setCode('AU')->shouldBeCalled();
     $china->setCode('CN')->shouldBeCalled();
     $france->setCode('FR')->shouldBeCalled();
     $countryRepository->add($australia)->shouldBeCalled();
     $countryRepository->add($china)->shouldBeCalled();
     $countryRepository->add($france)->shouldBeCalled();
     $nameToCodeConverter->convertToCode('Australia')->willReturn('AU');
     $nameToCodeConverter->convertToCode('China')->willReturn('CN');
     $nameToCodeConverter->convertToCode('France')->willReturn('FR');
     $this->storeShipsTo('Australia', 'China', 'France');
 }
Exemplo n.º 7
0
 /**
  * @param string $firstName
  * @param string $lastName
  * @param string $country
  * @param string $street
  * @param string $city
  * @param string $postcode
  *
  * @return AddressInterface
  */
 private function createAddress($firstName, $lastName, $country = 'United States', $street = 'Jones St. 114', $city = 'Paradise City', $postcode = '99999')
 {
     $address = $this->addressFactory->createNew();
     $address->setFirstName($firstName);
     $address->setLastName($lastName);
     $address->setStreet($street);
     $address->setCity($city);
     $address->setPostcode($postcode);
     $address->setCountryCode($this->countryCodeConverter->convertToCode($country));
     return $address;
 }
Exemplo n.º 8
0
 /**
  * @Transform /^address for "([^"]+)" from "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)"$/
  * @Transform /^"([^"]+)" addressed it to "([^"]+)", "([^"]+)" "([^"]+)" in the "([^"]+)"(?:|, "([^"]+)")$/
  * @Transform /^of "([^"]+)" in the "([^"]+)", "([^"]+)" "([^"]+)", "([^"]+)"(?:|, "([^"]+)")$/
  * @Transform /^addressed it to "([^"]+)", "([^"]+)", "([^"]+)" "([^"]+)" in the "([^"]+)"(?:|, "([^"]+)")$/
  * @Transform /^address (?:|is )"([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)"(?:|, "([^"]+)")$/
  * @Transform /^address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)"(?:|, "([^"]+)")$/
  */
 public function createNewAddressWithName($name, $street, $postcode, $city, $countryName, $provinceName = null)
 {
     $countryCode = $this->countryNameConverter->convertToCode($countryName);
     list($firstName, $lastName) = explode(' ', $name);
     return $this->createAddress($countryCode, $firstName, $lastName, $city, $street, $postcode, $provinceName);
 }
Exemplo n.º 9
0
 /**
  * @Transform /^address for "([^"]+)" from "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)"$/
  * @Transform /^"([^"]+)" addressed it to "([^"]+)", "([^"]+)" "([^"]+)" in the "([^"]+)"(?:|, "([^"]+)")$/
  * @Transform /^of "([^"]+)" in the "([^"]+)", "([^"]+)" "([^"]+)", "([^"]+)"(?:|, "([^"]+)")$/
  * @Transform /^addressed it to "([^"]+)", "([^"]+)", "([^"]+)" "([^"]+)" in the "([^"]+)"(?:|, "([^"]+)")$/
  * @Transform /^address (?:|is )"([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)"(?:|, "([^"]+)")$/
  * @Transform /^address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)"(?:|, "([^"]+)")$/
  */
 public function createNewAddressWithName($name, $street, $postcode, $city, $countryName, $provinceName = null)
 {
     $countryCode = $this->countryNameConverter->convertToCode($countryName);
     $names = explode(" ", $name);
     return $this->createAddress($countryCode, $names[0], $names[1], $city, $street, $postcode, $provinceName);
 }
Exemplo n.º 10
0
 /**
  * @Transform /^to "([^"]+)"$/
  */
 public function createNewAddress($countryName)
 {
     $countryCode = $this->countryNameConverter->convertToCode($countryName);
     return $this->createAddress($countryCode);
 }
Exemplo n.º 11
0
 function it_throws_invalid_argument_exception_when_cannot_convert_name_to_code(CountryNameConverterInterface $countryNameConverter)
 {
     $countryNameConverter->convertToCode('France')->willThrow(\InvalidArgumentException::class);
     $this->shouldThrow(\InvalidArgumentException::class)->during('getCountryByName', ['France']);
 }
Exemplo n.º 12
0
 /**
  * @Transform the :name country member
  */
 public function getCountryTypeZoneMemberByName($name)
 {
     $countryCode = $this->countryNameConverter->convertToCode($name);
     return $this->getZoneMemberByCode($countryCode);
 }