You are here

function Braintree_SubscriptionSearchTest::testSearch_daysPastDue in Commerce Braintree 7

File

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

Class

Braintree_SubscriptionSearchTest

Code

function testSearch_daysPastDue() {
  $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
  $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan();
  $subscription = Braintree_Subscription::create(array(
    'paymentMethodToken' => $creditCard->token,
    'planId' => $triallessPlan['id'],
  ))->subscription;
  Braintree_Http::put('/subscriptions/' . $subscription->id . '/make_past_due', array(
    'daysPastDue' => 5,
  ));
  $found = false;
  $collection = Braintree_Subscription::search(array(
    Braintree_SubscriptionSearch::daysPastDue()
      ->between(2, 10),
  ));
  foreach ($collection as $item) {
    $found = true;
    $this
      ->assertTrue($item->daysPastDue <= 10);
    $this
      ->assertTrue($item->daysPastDue >= 2);
  }
  $this
    ->assertTrue($found);
}