function Braintree_CreditCardTest::testUpdate_updatesExistingBillingAddressIfUpdateExistingOptionIsTrue in Commerce Braintree 7
File
- braintree_php/
tests/ integration/ CreditCardTest.php, line 732
Class
Code
function testUpdate_updatesExistingBillingAddressIfUpdateExistingOptionIsTrue() {
$customer = Braintree_Customer::createNoValidate();
$initialCreditCard = Braintree_CreditCard::create(array(
'customerId' => $customer->id,
'number' => '5105105105105100',
'expirationDate' => '05/12',
'billingAddress' => array(
'countryName' => 'Turkey',
'countryCodeAlpha2' => 'TR',
'countryCodeAlpha3' => 'TUR',
'countryCodeNumeric' => '792',
),
))->creditCard;
$updatedCreditCard = Braintree_CreditCard::update($initialCreditCard->token, array(
'billingAddress' => array(
'countryName' => 'Thailand',
'countryCodeAlpha2' => 'TH',
'countryCodeAlpha3' => 'THA',
'countryCodeNumeric' => '764',
'options' => array(
'updateExisting' => True,
),
),
))->creditCard;
$this
->assertEquals('Thailand', $updatedCreditCard->billingAddress->countryName);
$this
->assertEquals('TH', $updatedCreditCard->billingAddress->countryCodeAlpha2);
$this
->assertEquals('THA', $updatedCreditCard->billingAddress->countryCodeAlpha3);
$this
->assertEquals('764', $updatedCreditCard->billingAddress->countryCodeNumeric);
$this
->assertEquals($initialCreditCard->billingAddress->id, $updatedCreditCard->billingAddress->id);
}