コード例 #1
0
 private function setAddress(AddressInterface $address, AddressInterface $lastOrderAddress)
 {
     if ($address->getFirstName() === null) {
         $address->setFirstName($lastOrderAddress->getFirstName());
     }
     if ($address->getLastName() === null) {
         $address->setLastName($lastOrderAddress->getLastName());
     }
     if ($address->getPhoneNumber() === null) {
         $address->setPhoneNumber($lastOrderAddress->getPhoneNumber());
     }
     if ($address->getCountryCode() === null) {
         $address->setCountryCode($lastOrderAddress->getCountryCode());
     }
     if ($address->getProvinceCode() === null) {
         $address->setProvinceCode($lastOrderAddress->getProvinceCode());
     }
     if ($address->getStreet() === null) {
         $address->setStreet($lastOrderAddress->getStreet());
     }
     if ($address->getCity() === null) {
         $address->setCity($lastOrderAddress->getCity());
     }
     if ($address->getPostcode() === null) {
         $address->setPostcode($lastOrderAddress->getPostcode());
     }
 }
コード例 #2
0
 function it_should_recognize_subject_as_eligible_if_country_match(OrderInterface $subject, AddressInterface $address, CountryInterface $country, RepositoryInterface $countryRepository)
 {
     $country->getCode()->willReturn('IE');
     $address->getCountryCode()->willReturn('IE');
     $subject->getShippingAddress()->willReturn($address);
     $countryRepository->findOneBy(['code' => 'IE'])->willReturn($country);
     $this->isEligible($subject, ['country' => 'IE'])->shouldReturn(true);
 }
コード例 #3
0
ファイル: UpdatePage.php プロジェクト: Niiko/Sylius
 /**
  * {@inheritdoc}
  */
 private function specifyAddress(AddressInterface $address, $addressType)
 {
     $this->specifyElementValue($addressType . '_first_name', $address->getFirstName());
     $this->specifyElementValue($addressType . '_last_name', $address->getLastName());
     $this->specifyElementValue($addressType . '_street', $address->getStreet());
     $this->specifyElementValue($addressType . '_city', $address->getCity());
     $this->specifyElementValue($addressType . '_postcode', $address->getPostcode());
     $this->chooseCountry($address->getCountryCode(), $addressType);
 }
コード例 #4
0
 function it_adds_violation_because_address_has_no_province(AddressInterface $address, Country $country, ProvinceAddressConstraint $constraint, ExecutionContextInterface $context, RepositoryInterface $repository)
 {
     $country->getCode()->willReturn('IE');
     $address->getCountryCode()->willreturn('IE');
     $repository->findOneBy(array('code' => 'IE'))->willReturn($country);
     $country->hasProvinces()->willreturn(true);
     $address->getProvinceCode()->willreturn(null);
     $this->initialize($context);
     $context->getPropertyPath()->willReturn('property_path');
     $context->getViolations()->willReturn(new \ArrayIterator(array($this->createViolation('other_property_path'))));
     $context->addViolation(Argument::any())->shouldBeCalled();
     $this->validate($address, $constraint);
 }
コード例 #5
0
 function it_does_not_add_a_violation_if_province_is_valid(AddressInterface $address, Country $country, Province $province, ProvinceAddressConstraint $constraint, ExecutionContextInterface $context, RepositoryInterface $countryRepository, RepositoryInterface $provinceRepository)
 {
     $country->getCode()->willReturn('US');
     $address->getCountryCode()->willReturn('US');
     $countryRepository->findOneBy(['code' => 'US'])->willReturn($country);
     $country->hasProvinces()->willReturn(true);
     $address->getProvinceCode()->willReturn('US-AK');
     $province->getCode()->willReturn('US-AK');
     $provinceRepository->findOneBy(['code' => 'US-AK'])->willReturn($province);
     $country->hasProvince($province)->willReturn(true);
     $this->initialize($context);
     $context->getPropertyPath()->willReturn('property_path');
     $context->getViolations()->willReturn(new \ArrayIterator([$this->createViolation('other_property_path')]));
     $context->addViolation(Argument::any())->shouldNotBeCalled();
     $this->validate($address, $constraint);
 }
コード例 #6
0
 /**
  * @param AddressInterface $address
  *
  * @return bool
  */
 protected function isProvinceValid(AddressInterface $address)
 {
     $countryCode = $address->getCountryCode();
     if (null === ($country = $this->countryRepository->findOneBy(array('code' => $countryCode)))) {
         return true;
     }
     if (!$country->hasProvinces()) {
         return true;
     }
     if (null === $address->getProvinceCode()) {
         return false;
     }
     if ($country->hasProvince($address->getProvinceCode())) {
         return true;
     }
     return false;
 }
コード例 #7
0
ファイル: BaseDocument.php プロジェクト: enhavo/enhavo
 public function setAddress(AddressInterface $address)
 {
     $this->setCellMargins("", "", "", "");
     $this->SetFont(self::FONT);
     $this->SetFont(self::FONT_BOLD);
     if ($address->getCompany()) {
         $this->MultiCell(self::ADDRESS_WIDTH, 0, $address->getCompany(), 0, "L", false, 1, self::MARGIN_LEFT, self::MARGIN_TOP);
         $this->MultiCell(self::ADDRESS_WIDTH, 0, $address->getFirstName(), 0, "L", false, 1, self::MARGIN_LEFT);
     } else {
         $this->MultiCell(self::ADDRESS_WIDTH, 0, $address->getFirstName(), 0, "L", false, 1, self::MARGIN_LEFT, self::MARGIN_TOP);
     }
     $this->MultiCell(self::ADDRESS_WIDTH, 0, $address->getStreet(), 0, "L", false, 1, self::MARGIN_LEFT);
     $this->MultiCell(self::ADDRESS_WIDTH, 0, $address->getPostcode(), 0, "L", false, 1, self::MARGIN_LEFT);
     $country = $address->getCountryCode();
     $this->MultiCell(self::ADDRESS_WIDTH, 0, $country, 0, "L", false, 1, self::MARGIN_LEFT);
     if (!$address->getCompany()) {
         $this->MultiCell(self::ADDRESS_WIDTH, 0, "", 0, "L", false, 1, self::MARGIN_LEFT);
     }
 }
コード例 #8
0
 function it_matches_all_zones_by_scope_when_one_zone_for_address_is_defined(RepositoryInterface $repository, AddressInterface $address, ZoneMemberInterface $memberCountry, ZoneInterface $zoneCountry)
 {
     $repository->findBy(['scope' => 'shipping'])->willReturn([$zoneCountry]);
     $address->getCountryCode()->willReturn('US');
     $memberCountry->getCode()->willReturn('US');
     $zoneCountry->getType()->willReturn(ZoneInterface::TYPE_COUNTRY);
     $zoneCountry->getMembers()->willReturn([$memberCountry]);
     $memberCountry->getBelongsTo()->willReturn($zoneCountry);
     $this->matchAll($address, 'shipping')->shouldReturn([$zoneCountry]);
 }
コード例 #9
0
 function it_ignores_leading_and_trailing_spaces_or_letter_cases(AddressInterface $firstAddress, AddressInterface $secondAddress)
 {
     $firstAddress->getCity()->willReturn('TOOWOOMBA');
     $firstAddress->getStreet()->willReturn('Ryans Dr     ');
     $firstAddress->getCompany()->willReturn('   Burger');
     $firstAddress->getPostcode()->willReturn(' 4350 ');
     $firstAddress->getLastName()->willReturn('jones ');
     $firstAddress->getFirstName()->willReturn('mIa');
     $firstAddress->getPhoneNumber()->willReturn(' 999');
     $firstAddress->getCountryCode()->willReturn('au');
     $firstAddress->getProvinceCode()->willReturn(null);
     $firstAddress->getProvinceName()->willReturn('qUEENSLAND');
     $secondAddress->getCity()->willReturn('Toowoomba');
     $secondAddress->getStreet()->willReturn('Ryans Dr');
     $secondAddress->getCompany()->willReturn('Burger');
     $secondAddress->getPostcode()->willReturn('4350');
     $secondAddress->getLastName()->willReturn('Jones');
     $secondAddress->getFirstName()->willReturn('Mia');
     $secondAddress->getPhoneNumber()->willReturn('999');
     $secondAddress->getCountryCode()->willReturn('AU');
     $secondAddress->getProvinceCode()->willReturn(null);
     $secondAddress->getProvinceName()->willReturn('Queensland');
     $this->equal($firstAddress, $secondAddress)->shouldReturn(true);
 }
コード例 #10
0
ファイル: ZoneMatcher.php プロジェクト: sidibea/Sylius
 /**
  * @param AddressInterface    $address
  * @param ZoneMemberInterface $member
  *
  * @return bool
  *
  * @throws \InvalidArgumentException
  */
 protected function addressBelongsToZoneMember(AddressInterface $address, ZoneMemberInterface $member)
 {
     switch ($type = $member->getBelongsTo()->getType()) {
         case ZoneInterface::TYPE_PROVINCE:
             return null !== $address->getProvinceCode() && $address->getProvinceCode() === $member->getCode();
         case ZoneInterface::TYPE_COUNTRY:
             return null !== $address->getCountryCode() && $address->getCountryCode() === $member->getCode();
         case ZoneInterface::TYPE_ZONE:
             $zone = $this->getZoneByCode($member->getCode());
             return $this->addressBelongsToZone($address, $zone);
         default:
             throw new \InvalidArgumentException(sprintf('Unexpected zone type "%s".', $type));
     }
 }
コード例 #11
0
ファイル: AddressComparator.php プロジェクト: loic425/Sylius
 /**
  * @param AddressInterface $address
  *
  * @return array
  */
 private function normalizeAddress(AddressInterface $address)
 {
     return array_map(function ($value) {
         return trim(strtolower($value));
     }, [$address->getCity(), $address->getCompany(), $address->getCountryCode(), $address->getFirstName(), $address->getLastName(), $address->getPhoneNumber(), $address->getPostcode(), $address->getProvinceCode(), $address->getProvinceName(), $address->getStreet()]);
 }