function Braintree_SubscriptionTest::testCreate_whenSuccessful in Commerce Braintree 7
File
- braintree_php/
tests/ integration/ SubscriptionTest.php, line 15
Class
Code
function testCreate_whenSuccessful() {
$creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
$plan = Braintree_SubscriptionTestHelper::triallessPlan();
$result = Braintree_Subscription::create(array(
'paymentMethodToken' => $creditCard->token,
'planId' => $plan['id'],
));
Braintree_TestHelper::assertPrintable($result);
$this
->assertTrue($result->success);
$subscription = $result->subscription;
$this
->assertEquals($creditCard->token, $subscription->paymentMethodToken);
$this
->assertEquals(0, $subscription->failureCount);
$this
->assertEquals($plan['id'], $subscription->planId);
$this
->assertEquals(Braintree_TestHelper::defaultMerchantAccountId(), $subscription->merchantAccountId);
$this
->assertEquals(Braintree_Subscription::ACTIVE, $subscription->status);
$this
->assertEquals('12.34', $subscription->nextBillAmount);
$this
->assertEquals('12.34', $subscription->nextBillingPeriodAmount);
$this
->assertEquals('0.00', $subscription->balance);
$this
->assertEquals(1, $subscription->currentBillingCycle);
$this
->assertType('DateTime', $subscription->firstBillingDate);
$this
->assertType('DateTime', $subscription->nextBillingDate);
$this
->assertType('DateTime', $subscription->billingPeriodStartDate);
$this
->assertType('DateTime', $subscription->billingPeriodEndDate);
$this
->assertType('DateTime', $subscription->paidThroughDate);
}