You are here

function Braintree_SubscriptionTest::testUpdate_canUpdatePaymentMethodToken in Commerce Braintree 7

File

braintree_php/tests/integration/SubscriptionTest.php, line 754

Class

Braintree_SubscriptionTest

Code

function testUpdate_canUpdatePaymentMethodToken() {
  $oldCreditCard = Braintree_SubscriptionTestHelper::createCreditCard();
  $plan = Braintree_SubscriptionTestHelper::triallessPlan();
  $subscription = Braintree_Subscription::create(array(
    'paymentMethodToken' => $oldCreditCard->token,
    'price' => '54.99',
    'planId' => $plan['id'],
  ))->subscription;
  $newCreditCard = Braintree_CreditCard::createNoValidate(array(
    'number' => '5105105105105100',
    'expirationDate' => '05/2010',
    'customerId' => $oldCreditCard->customerId,
  ));
  $result = Braintree_Subscription::update($subscription->id, array(
    'paymentMethodToken' => $newCreditCard->token,
  ));
  $this
    ->assertTrue($result->success);
  $this
    ->assertEquals($newCreditCard->token, $result->subscription->paymentMethodToken);
}