You are here

function Braintree_SubscriptionSearchTest::testSearch_billingCyclesRemaing in Commerce Braintree 7

File

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

Class

Braintree_SubscriptionSearchTest

Code

function testSearch_billingCyclesRemaing() {
  $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
  $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan();
  $subscription_4 = Braintree_Subscription::create(array(
    'paymentMethodToken' => $creditCard->token,
    'planId' => $triallessPlan['id'],
    'numberOfBillingCycles' => 4,
  ))->subscription;
  $subscription_8 = Braintree_Subscription::create(array(
    'paymentMethodToken' => $creditCard->token,
    'planId' => $triallessPlan['id'],
    'numberOfBillingCycles' => 8,
  ))->subscription;
  $subscription_10 = Braintree_Subscription::create(array(
    'paymentMethodToken' => $creditCard->token,
    'planId' => $triallessPlan['id'],
    'numberOfBillingCycles' => 10,
  ))->subscription;
  $collection = Braintree_Subscription::search(array(
    Braintree_SubscriptionSearch::billingCyclesRemaining()
      ->between(5, 10),
  ));
  $this
    ->assertFalse(Braintree_TestHelper::includes($collection, $subscription_4));
  $this
    ->assertTrue(Braintree_TestHelper::includes($collection, $subscription_8));
  $this
    ->assertTrue(Braintree_TestHelper::includes($collection, $subscription_10));
}