Tests sorting and range on config entity queries.
protected function testSortRange() {
  // Sort by simple ascending/descending.
  $this->queryResults = $this->factory
    ->get('config_query_test')
    ->sort('number', 'DESC')
    ->execute();
  $this
    ->assertIdentical(array_values($this->queryResults), array(
    '3',
    '5',
    '2',
    '1',
    '4',
  ));
  $this->queryResults = $this->factory
    ->get('config_query_test')
    ->sort('number', 'ASC')
    ->execute();
  $this
    ->assertIdentical(array_values($this->queryResults), array(
    '4',
    '1',
    '2',
    '5',
    '3',
  ));
  // Apply some filters and sort.
  $this->queryResults = $this->factory
    ->get('config_query_test')
    ->condition('id', '3', '>')
    ->sort('number', 'DESC')
    ->execute();
  $this
    ->assertIdentical(array_values($this->queryResults), array(
    '5',
    '4',
  ));
  $this->queryResults = $this->factory
    ->get('config_query_test')
    ->condition('id', '3', '>')
    ->sort('number', 'ASC')
    ->execute();
  $this
    ->assertIdentical(array_values($this->queryResults), array(
    '4',
    '5',
  ));
  // Apply a pager and sort.
  $this->queryResults = $this->factory
    ->get('config_query_test')
    ->sort('number', 'DESC')
    ->range('2', '2')
    ->execute();
  $this
    ->assertIdentical(array_values($this->queryResults), array(
    '2',
    '1',
  ));
  $this->queryResults = $this->factory
    ->get('config_query_test')
    ->sort('number', 'ASC')
    ->range('2', '2')
    ->execute();
  $this
    ->assertIdentical(array_values($this->queryResults), array(
    '2',
    '5',
  ));
  // Add a range to a query without a start parameter.
  $this->queryResults = $this->factory
    ->get('config_query_test')
    ->range(0, '3')
    ->sort('id', 'ASC')
    ->execute();
  $this
    ->assertIdentical(array_values($this->queryResults), array(
    '1',
    '2',
    '3',
  ));
  // Apply a pager with limit 4.
  $this->queryResults = $this->factory
    ->get('config_query_test')
    ->pager('4', 0)
    ->sort('id', 'ASC')
    ->execute();
  $this
    ->assertIdentical(array_values($this->queryResults), array(
    '1',
    '2',
    '3',
    '4',
  ));
}