You are here

function Braintree_CreditCardTest::testCreate_withBillingAddress in Commerce Braintree 7

File

braintree_php/tests/integration/CreditCardTest.php, line 140

Class

Braintree_CreditCardTest

Code

function testCreate_withBillingAddress() {
  $customer = Braintree_Customer::createNoValidate();
  $result = Braintree_CreditCard::create(array(
    'customerId' => $customer->id,
    'cardholderName' => 'Peter Tomlin',
    'number' => '5105105105105100',
    'expirationDate' => '05/12',
    'billingAddress' => array(
      'firstName' => 'Drew',
      'lastName' => 'Smith',
      'company' => 'Smith Co.',
      'streetAddress' => '1 E Main St',
      'extendedAddress' => 'Suite 101',
      'locality' => 'Chicago',
      'region' => 'IL',
      'postalCode' => '60622',
      'countryName' => 'Micronesia',
      'countryCodeAlpha2' => 'FM',
      'countryCodeAlpha3' => 'FSM',
      'countryCodeNumeric' => '583',
    ),
  ));
  $this
    ->assertTrue($result->success);
  $this
    ->assertEquals($customer->id, $result->creditCard->customerId);
  $this
    ->assertEquals('510510', $result->creditCard->bin);
  $this
    ->assertEquals('5100', $result->creditCard->last4);
  $this
    ->assertEquals('Peter Tomlin', $result->creditCard->cardholderName);
  $this
    ->assertEquals('05/2012', $result->creditCard->expirationDate);
  $address = $result->creditCard->billingAddress;
  $this
    ->assertEquals('Drew', $address->firstName);
  $this
    ->assertEquals('Smith', $address->lastName);
  $this
    ->assertEquals('Smith Co.', $address->company);
  $this
    ->assertEquals('1 E Main St', $address->streetAddress);
  $this
    ->assertEquals('Suite 101', $address->extendedAddress);
  $this
    ->assertEquals('Chicago', $address->locality);
  $this
    ->assertEquals('IL', $address->region);
  $this
    ->assertEquals('60622', $address->postalCode);
  $this
    ->assertEquals('Micronesia', $address->countryName);
  $this
    ->assertEquals('FM', $address->countryCodeAlpha2);
  $this
    ->assertEquals('FSM', $address->countryCodeAlpha3);
  $this
    ->assertEquals('583', $address->countryCodeNumeric);
}