You are here

function Braintree_CustomerTest::testUpdate_withCountry in Commerce Braintree 7

File

braintree_php/tests/integration/CustomerTest.php, line 405

Class

Braintree_CustomerTest

Code

function testUpdate_withCountry() {
  $customer = Braintree_Customer::create(array(
    'firstName' => 'Bat',
    'lastName' => 'Manderson',
    'creditCard' => array(
      'number' => '5105105105105100',
      'expirationDate' => '05/12',
      'billingAddress' => array(
        'countryName' => 'United States of America',
        'countryCodeAlpha2' => 'US',
        'countryCodeAlpha3' => 'USA',
        'countryCodeNumeric' => '840',
      ),
    ),
  ))->customer;
  $result = Braintree_Customer::update($customer->id, array(
    'firstName' => 'Bat',
    'lastName' => 'Manderson',
    'creditCard' => array(
      'options' => array(
        'updateExistingToken' => $customer->creditCards[0]->token,
      ),
      'billingAddress' => array(
        'countryName' => 'Gabon',
        'countryCodeAlpha2' => 'GA',
        'countryCodeAlpha3' => 'GAB',
        'countryCodeNumeric' => '266',
        'options' => array(
          'updateExisting' => true,
        ),
      ),
    ),
  ));
  $this
    ->assertEquals(true, $result->success);
  $updatedCustomer = $result->customer;
  $this
    ->assertEquals('Gabon', $updatedCustomer->creditCards[0]->billingAddress->countryName);
  $this
    ->assertEquals('GA', $updatedCustomer->creditCards[0]->billingAddress->countryCodeAlpha2);
  $this
    ->assertEquals('GAB', $updatedCustomer->creditCards[0]->billingAddress->countryCodeAlpha3);
  $this
    ->assertEquals('266', $updatedCustomer->creditCards[0]->billingAddress->countryCodeNumeric);
}