You are here

function Braintree_AddressTest::testUpdate in Commerce Braintree 7

File

braintree_php/tests/integration/AddressTest.php, line 148

Class

Braintree_AddressTest

Code

function testUpdate() {
  $customer = Braintree_Customer::createNoValidate();
  $address = Braintree_Address::createNoValidate(array(
    'customerId' => $customer->id,
    'firstName' => 'Old First',
    'lastName' => 'Old Last',
    'company' => 'Old Company',
    'streetAddress' => '1 E Old St',
    'extendedAddress' => 'Apt Old',
    'locality' => 'Old Chicago',
    'region' => 'Old Region',
    'postalCode' => 'Old Postal',
    'countryName' => 'United States of America',
    'countryCodeAlpha2' => 'US',
    'countryCodeAlpha3' => 'USA',
    'countryCodeNumeric' => '840',
  ));
  $result = Braintree_Address::update($customer->id, $address->id, array(
    'firstName' => 'New First',
    'lastName' => 'New Last',
    'company' => 'New Company',
    'streetAddress' => '1 E New St',
    'extendedAddress' => 'Apt New',
    'locality' => 'New Chicago',
    'region' => 'New Region',
    'postalCode' => 'New Postal',
    'countryName' => 'Mexico',
    'countryCodeAlpha2' => 'MX',
    'countryCodeAlpha3' => 'MEX',
    'countryCodeNumeric' => '484',
  ));
  $this
    ->assertTrue($result->success);
  $address = $result->address;
  $this
    ->assertEquals('New First', $address->firstName);
  $this
    ->assertEquals('New Last', $address->lastName);
  $this
    ->assertEquals('New Company', $address->company);
  $this
    ->assertEquals('1 E New St', $address->streetAddress);
  $this
    ->assertEquals('Apt New', $address->extendedAddress);
  $this
    ->assertEquals('New Chicago', $address->locality);
  $this
    ->assertEquals('New Region', $address->region);
  $this
    ->assertEquals('New Postal', $address->postalCode);
  $this
    ->assertEquals('Mexico', $address->countryName);
  $this
    ->assertEquals('MX', $address->countryCodeAlpha2);
  $this
    ->assertEquals('MEX', $address->countryCodeAlpha3);
  $this
    ->assertEquals('484', $address->countryCodeNumeric);
}