You are here

function Braintree_CreditCardTest::testCreate in Commerce Braintree 7

File

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

Class

Braintree_CreditCardTest

Code

function testCreate() {
  $customer = Braintree_Customer::createNoValidate();
  $result = Braintree_CreditCard::create(array(
    'customerId' => $customer->id,
    'cardholderName' => 'Cardholder',
    'number' => '5105105105105100',
    'expirationDate' => '05/12',
  ));
  $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('Cardholder', $result->creditCard->cardholderName);
  $this
    ->assertEquals('05/2012', $result->creditCard->expirationDate);
  $this
    ->assertEquals(1, preg_match('/\\A\\w{32}\\z/', $result->creditCard->uniqueNumberIdentifier));
}