1 entity_query.test EntityFieldQueryTestCase::testEntityFieldQueryPager()

Tests the pager integration of EntityFieldQuery.

File

core/modules/entity/tests/entity_query.test, line 1273
Unit test file for the entity API.

Class

EntityFieldQueryTestCase
Tests EntityFieldQuery.

Code

function testEntityFieldQueryPager() {
  // Test pager in propertyQuery
  $_GET['page'] = '0,1';
  $query = new EntityFieldQuery();
  $query
  ->entityCondition('entity_type', 'test_entity_bundle_key')
    ->propertyOrderBy('ftid', 'ASC')
    ->pager(3, 0);
  $this->assertEntityFieldQuery($query, array(
    array('test_entity_bundle_key', 1),
    array('test_entity_bundle_key', 2),
    array('test_entity_bundle_key', 3),
  ), 'Test pager integration in propertyQuery: page 1.', TRUE);

  $query = new EntityFieldQuery();
  $query
  ->entityCondition('entity_type', 'test_entity_bundle_key')
    ->propertyOrderBy('ftid', 'ASC')
    ->pager(3, 1);
  $this->assertEntityFieldQuery($query, array(
    array('test_entity_bundle_key', 4),
    array('test_entity_bundle_key', 5),
    array('test_entity_bundle_key', 6),
  ), 'Test pager integration in propertyQuery: page 2.', TRUE);

  // Test pager in field storage
  $_GET['page'] = '0,1';
  $query = new EntityFieldQuery();
  $query
  ->entityCondition('entity_type', 'test_entity_bundle_key')
    ->fieldCondition($this->fields[0], 'value', 0, '>')
    ->propertyOrderBy('ftid', 'ASC')
    ->pager(2, 0);
  $this->assertEntityFieldQuery($query, array(
    array('test_entity_bundle_key', 1),
    array('test_entity_bundle_key', 2),
  ), 'Test pager integration in field storage: page 1.', TRUE);

  $query = new EntityFieldQuery();
  $query
  ->entityCondition('entity_type', 'test_entity_bundle_key')
    ->fieldCondition($this->fields[0], 'value', 0, '>')
    ->propertyOrderBy('ftid', 'ASC')
    ->pager(2, 1);
  $this->assertEntityFieldQuery($query, array(
    array('test_entity_bundle_key', 3),
    array('test_entity_bundle_key', 4),
  ), 'Test pager integration in field storage: page 2.', TRUE);

  unset($_GET['page']);
}