/**
  * {@inheritdoc}
  */
 public function add(CustomerInterface $customer, AddressInterface $address)
 {
     foreach ($customer->getAddresses() as $customerAddress) {
         if ($this->addressComparator->equal($customerAddress, $address)) {
             return;
         }
     }
     $customer->addAddress($address);
 }
 function it_adds_an_address_when_different_than_the_ones_present_on_the_customer(AddressComparatorInterface $addressComparator, CustomerInterface $customer, AddressInterface $customerAddress, AddressInterface $newAddress, Collection $addresses, \Iterator $iterator)
 {
     $iterator->rewind()->shouldBeCalled();
     $iterator->valid()->willReturn(true);
     $iterator->current()->willReturn($customerAddress);
     $iterator->valid()->willReturn(false);
     $addresses->getIterator()->willReturn($iterator);
     $customer->getAddresses()->willReturn($addresses);
     $addressComparator->equal($customerAddress, $newAddress)->willReturn(false);
     $customer->addAddress($newAddress)->shouldBeCalled();
     $this->add($customer, $newAddress);
 }
Esempio n. 3
0
 /**
  * @Then /^(address "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+") should be filled as billing address$/
  */
 public function addressShouldBeFilledAsBillingAddress(AddressInterface $address)
 {
     Assert::true($this->addressComparator->equal($address, $this->addressPage->getPreFilledBillingAddress()));
 }