You are here

function Braintree_SubscriptionSearchTest::testSearch_transactionId in Commerce Braintree 7

File

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

Class

Braintree_SubscriptionSearchTest

Code

function testSearch_transactionId() {
  $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
  $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan();
  $matchingSubscription = Braintree_Subscription::create(array(
    'paymentMethodToken' => $creditCard->token,
    'planId' => $triallessPlan['id'],
  ))->subscription;
  $nonMatchingSubscription = Braintree_Subscription::create(array(
    'paymentMethodToken' => $creditCard->token,
    'planId' => $triallessPlan['id'],
  ))->subscription;
  $collection = Braintree_Subscription::search(array(
    Braintree_SubscriptionSearch::transactionId()
      ->is($matchingSubscription->transactions[0]->id),
  ));
  $this
    ->assertTrue(Braintree_TestHelper::includes($collection, $matchingSubscription));
  $this
    ->assertFalse(Braintree_TestHelper::includes($collection, $nonMatchingSubscription));
}