You are here

function Braintree_SubscriptionSearchTest::testSearch_nextBillingDate in Commerce Braintree 7

File

braintree_php/tests/integration/SubscriptionSearchTest.php, line 263

Class

Braintree_SubscriptionSearchTest

Code

function testSearch_nextBillingDate() {
  $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
  $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan();
  $trialPlan = Braintree_SubscriptionTestHelper::trialPlan();
  $triallessSubscription = Braintree_Subscription::create(array(
    'paymentMethodToken' => $creditCard->token,
    'planId' => $triallessPlan['id'],
  ))->subscription;
  $trialSubscription = Braintree_Subscription::create(array(
    'paymentMethodToken' => $creditCard->token,
    'planId' => $trialPlan['id'],
  ))->subscription;
  $fiveDaysFromNow = new DateTime();
  $fiveDaysFromNow
    ->modify("+5 days");
  $collection = Braintree_Subscription::search(array(
    Braintree_SubscriptionSearch::nextBillingDate()
      ->greaterThanOrEqualTo($fiveDaysFromNow),
  ));
  $this
    ->assertTrue(Braintree_TestHelper::includes($collection, $triallessSubscription));
  $this
    ->assertFalse(Braintree_TestHelper::includes($collection, $trialSubscription));
}