You are here

function Braintree_CreditCardTest::testCreate_withDefault in Commerce Braintree 7

File

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

Class

Braintree_CreditCardTest

Code

function testCreate_withDefault() {
  $customer = Braintree_Customer::createNoValidate();
  $card1 = Braintree_CreditCard::create(array(
    'customerId' => $customer->id,
    'cardholderName' => 'Cardholder',
    'number' => '5105105105105100',
    'expirationDate' => '05/12',
  ))->creditCard;
  $this
    ->assertTrue($card1
    ->isDefault());
  $card2 = Braintree_CreditCard::create(array(
    'customerId' => $customer->id,
    'cardholderName' => 'Cardholder',
    'number' => '5105105105105100',
    'expirationDate' => '05/12',
    'options' => array(
      'makeDefault' => true,
    ),
  ))->creditCard;
  $card1 = Braintree_CreditCard::find($card1->token);
  $this
    ->assertFalse($card1
    ->isDefault());
  $this
    ->assertTrue($card2
    ->isDefault());
}