You are here

function Braintree_SubscriptionTest::testCreate_createsATransactionIfNoTrialPeriod in Commerce Braintree 7

File

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

Class

Braintree_SubscriptionTest

Code

function testCreate_createsATransactionIfNoTrialPeriod() {
  $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
  $plan = Braintree_SubscriptionTestHelper::triallessPlan();
  $result = Braintree_Subscription::create(array(
    'paymentMethodToken' => $creditCard->token,
    'planId' => $plan['id'],
  ));
  $subscription = $result->subscription;
  $this
    ->assertEquals(1, sizeof($subscription->transactions));
  $transaction = $subscription->transactions[0];
  $this
    ->assertType('Braintree_Transaction', $transaction);
  $this
    ->assertEquals($plan['price'], $transaction->amount);
  $this
    ->assertEquals(Braintree_Transaction::SALE, $transaction->type);
  $this
    ->assertEquals($subscription->id, $transaction->subscriptionId);
}