You are here

function Braintree_CustomerTest::testCreate_withCreditCard in Commerce Braintree 7

File

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

Class

Braintree_CustomerTest

Code

function testCreate_withCreditCard() {
  $result = Braintree_Customer::create(array(
    'firstName' => 'Mike',
    'lastName' => 'Jones',
    'company' => 'Jones Co.',
    'email' => 'mike.jones@example.com',
    'phone' => '419.555.1234',
    'fax' => '419.555.1235',
    'website' => 'http://example.com',
    'creditCard' => array(
      'number' => '5105105105105100',
      'expirationDate' => '05/12',
      'cvv' => '123',
      'cardholderName' => 'Mike Jones',
    ),
  ));
  $this
    ->assertEquals(true, $result->success);
  $customer = $result->customer;
  $this
    ->assertEquals('Mike', $customer->firstName);
  $this
    ->assertEquals('Jones', $customer->lastName);
  $this
    ->assertEquals('Jones Co.', $customer->company);
  $this
    ->assertEquals('mike.jones@example.com', $customer->email);
  $this
    ->assertEquals('419.555.1234', $customer->phone);
  $this
    ->assertEquals('419.555.1235', $customer->fax);
  $this
    ->assertEquals('http://example.com', $customer->website);
  $creditCard = $customer->creditCards[0];
  $this
    ->assertEquals('510510', $creditCard->bin);
  $this
    ->assertEquals('5100', $creditCard->last4);
  $this
    ->assertEquals('Mike Jones', $creditCard->cardholderName);
  $this
    ->assertEquals('05/2012', $creditCard->expirationDate);
  $this
    ->assertEquals('05', $creditCard->expirationMonth);
  $this
    ->assertEquals('2012', $creditCard->expirationYear);
}