You are here

function Braintree_SubscriptionTest::testCreate_firstBillingDateInThePast in Commerce Braintree 7

File

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

Class

Braintree_SubscriptionTest

Code

function testCreate_firstBillingDateInThePast() {
  $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
  $plan = Braintree_SubscriptionTestHelper::billingDayOfMonthPlan();
  $past = new DateTime("now - 3 days");
  $past
    ->setTime(0, 0, 0);
  $result = Braintree_Subscription::create(array(
    'paymentMethodToken' => $creditCard->token,
    'planId' => $plan['id'],
    'firstBillingDate' => $past,
  ));
  $this
    ->assertFalse($result->success);
  $errors = $result->errors
    ->forKey('subscription')
    ->onAttribute('firstBillingDate');
  $this
    ->assertEquals(Braintree_Error_Codes::SUBSCRIPTION_FIRST_BILLING_DATE_CANNOT_BE_IN_THE_PAST, $errors[0]->code);
}