function Braintree_TransactionAdvancedSearchTest::test_rangeNode_createdAt_between in Commerce Braintree 7
File
- braintree_php/
tests/ integration/ TransactionAdvancedSearchTest.php, line 745
Class
Code
function test_rangeNode_createdAt_between() {
$transaction = Braintree_Transaction::saleNoValidate(array(
'amount' => '1000.00',
'creditCard' => array(
'cardholderName' => 'Ted Everyman' . rand(),
'number' => '5105105105105100',
'expirationDate' => '05/12',
),
));
$past = clone $transaction->createdAt;
$past
->modify("-1 hour");
$now = $transaction->createdAt;
$future = clone $transaction->createdAt;
$future
->modify("+1 hour");
$future2 = clone $transaction->createdAt;
$future2
->modify("+1 day");
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::creditCardCardholderName()
->is($transaction->creditCardDetails->cardholderName),
Braintree_TransactionSearch::createdAt()
->between($past, $future),
));
$this
->assertEquals(1, $collection
->maximumCount());
$this
->assertEquals($transaction->id, $collection
->firstItem()->id);
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::creditCardCardholderName()
->is($transaction->creditCardDetails->cardholderName),
Braintree_TransactionSearch::createdAt()
->between($now, $future),
));
$this
->assertEquals(1, $collection
->maximumCount());
$this
->assertEquals($transaction->id, $collection
->firstItem()->id);
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::creditCardCardholderName()
->is($transaction->creditCardDetails->cardholderName),
Braintree_TransactionSearch::createdAt()
->between($past, $now),
));
$this
->assertEquals(1, $collection
->maximumCount());
$this
->assertEquals($transaction->id, $collection
->firstItem()->id);
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::creditCardCardholderName()
->is($transaction->creditCardDetails->cardholderName),
Braintree_TransactionSearch::createdAt()
->between($future, $future2),
));
$this
->assertEquals(0, $collection
->maximumCount());
}