You are here

function Braintree_TransactionAdvancedSearchTest::testStartsWith in Commerce Braintree 7

File

braintree_php/tests/integration/TransactionAdvancedSearchTest.php, line 225

Class

Braintree_TransactionAdvancedSearchTest

Code

function testStartsWith() {
  $transaction = Braintree_Transaction::saleNoValidate(array(
    'amount' => Braintree_Test_TransactionAmounts::$authorize,
    'creditCard' => array(
      'number' => Braintree_Test_CreditCardNumbers::$visa,
      'expirationDate' => '05/2012',
      'cardholderName' => 'tom smith',
    ),
  ));
  $collection = Braintree_Transaction::search(array(
    Braintree_TransactionSearch::id()
      ->is($transaction->id),
    Braintree_TransactionSearch::creditCardCardholderName()
      ->startsWith('tom s'),
  ));
  $this
    ->assertEquals(1, $collection
    ->maximumCount());
  $this
    ->assertEquals($transaction->id, $collection
    ->firstItem()->id);
  $collection = Braintree_Transaction::search(array(
    Braintree_TransactionSearch::id()
      ->is($transaction->id),
    Braintree_TransactionSearch::creditCardCardholderName()
      ->startsWith('m smith'),
  ));
  $this
    ->assertEquals(0, $collection
    ->maximumCount());
}