function Braintree_TransactionAdvancedSearchTest::test_rangeNode_createdAt_GreaterThanOrEqualTo in Commerce Braintree 7
File
- braintree_php/
tests/ integration/ TransactionAdvancedSearchTest.php, line 708
Class
Code
function test_rangeNode_createdAt_GreaterThanOrEqualTo() {
$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");
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::creditCardCardholderName()
->is($transaction->creditCardDetails->cardholderName),
Braintree_TransactionSearch::createdAt()
->GreaterThanOrEqualTo($future),
));
$this
->assertEquals(0, $collection
->maximumCount());
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::creditCardCardholderName()
->is($transaction->creditCardDetails->cardholderName),
Braintree_TransactionSearch::createdAt()
->GreaterThanOrEqualTo($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()
->GreaterThanOrEqualTo($past),
));
$this
->assertEquals(1, $collection
->maximumCount());
$this
->assertEquals($transaction->id, $collection
->firstItem()->id);
}