You are here

function Braintree_CustomerAdvancedSearchTest::test_createdAt in Commerce Braintree 7

File

braintree_php/tests/integration/CustomerAdvancedSearchTest.php, line 129

Class

Braintree_CustomerAdvancedSearchTest

Code

function test_createdAt() {
  $customer = Braintree_Customer::createNoValidate();
  $past = clone $customer->createdAt;
  $past
    ->modify("-1 hour");
  $future = clone $customer->createdAt;
  $future
    ->modify("+1 hour");
  $collection = Braintree_Customer::search(array(
    Braintree_CustomerSearch::id()
      ->is($customer->id),
    Braintree_CustomerSearch::createdAt()
      ->between($past, $future),
  ));
  $this
    ->assertEquals(1, $collection
    ->maximumCount());
  $this
    ->assertEquals($customer->id, $collection
    ->firstItem()->id);
  $collection = Braintree_Customer::search(array(
    Braintree_CustomerSearch::id()
      ->is($customer->id),
    Braintree_CustomerSearch::createdAt()
      ->lessThanOrEqualTo($future),
  ));
  $this
    ->assertEquals(1, $collection
    ->maximumCount());
  $this
    ->assertEquals($customer->id, $collection
    ->firstItem()->id);
  $collection = Braintree_Customer::search(array(
    Braintree_CustomerSearch::id()
      ->is($customer->id),
    Braintree_CustomerSearch::createdAt()
      ->greaterThanOrEqualTo($past),
  ));
  $this
    ->assertEquals(1, $collection
    ->maximumCount());
  $this
    ->assertEquals($customer->id, $collection
    ->firstItem()->id);
}