/** * same_as_billing must be equal 0 if customer has default shipping address that differs from default billing * * @magentoDbIsolation enabled */ public function testSameAsBillingWhenCustomerHasDefaultShippingAddress() { /** @var \Magento\Customer\Api\AddressRepositoryInterface $addressRepository */ $addressRepository = Bootstrap::getObjectManager()->create('Magento\\Customer\\Api\\AddressRepositoryInterface'); $this->_customer->setDefaultShipping(2)->setAddresses([$addressRepository->getById($this->_address->getId())]); $this->_customer = $this->customerRepository->save($this->_customer); // we should save the customer data in order to be able to use it $this->_quote->setCustomer($this->_customer); $sameAsBilling = $this->_quote->getShippingAddress()->getSameAsBilling(); $this->assertEquals(1, $sameAsBilling); }
/** * Return id for address * * @param Address $address * @return string */ private function _getAddressId($address) { if ($address instanceof Address) { return $address->getId(); } return $address; }