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());
     }
 }
 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);
 }
Exemple #3
0
 /**
  * @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()]);
 }