You are here

function Braintree_SubscriptionSearchTest::testSearch_merchantAccountId in Commerce Braintree 7

File

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

Class

Braintree_SubscriptionSearchTest

Code

function testSearch_merchantAccountId() {
  $creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
  $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan();
  $rand_id = strval(rand());
  $subscription_1 = Braintree_Subscription::create(array(
    'paymentMethodToken' => $creditCard->token,
    'planId' => $triallessPlan['id'],
    'id' => strval(rand()) . '_subscription_' . $rand_id,
    'price' => '2',
  ))->subscription;
  $subscription_2 = Braintree_Subscription::create(array(
    'paymentMethodToken' => $creditCard->token,
    'planId' => $triallessPlan['id'],
    'id' => strval(rand()) . '_subscription_' . $rand_id,
    'merchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId(),
    'price' => '2',
  ))->subscription;
  $collection = Braintree_Subscription::search(array(
    Braintree_SubscriptionSearch::id()
      ->endsWith('subscription_' . $rand_id),
    Braintree_SubscriptionSearch::merchantAccountId()
      ->in(array(
      Braintree_TestHelper::nonDefaultMerchantAccountId(),
    )),
    Braintree_SubscriptionSearch::price()
      ->is('2'),
  ));
  $this
    ->assertFalse(Braintree_TestHelper::includes($collection, $subscription_1));
  $this
    ->assertTrue(Braintree_TestHelper::includes($collection, $subscription_2));
}