You are here

function EFQViewsSortTestCase::runTestView in EntityFieldQuery Views Backend 7

1 call to EFQViewsSortTestCase::runTestView()
EFQViewsSortTestCase::testSort in tests/efq_views.test

File

tests/efq_views.test, line 399
Tests for EFQ Views query features.

Class

EFQViewsSortTestCase

Code

function runTestView($field, $expected_result) {
  $view = new view();
  $view->base_table = 'efq_efq_views_test';
  $handler = $view
    ->new_display('default');
  $handler->display->display_options['row_options']['default_field_elements'] = FALSE;
  $handler->display->display_options['fields']['entity_id']['id'] = 'entity_id';
  $handler->display->display_options['fields']['entity_id']['field'] = 'entity_id';
  $handler->display->display_options['fields']['entity_id']['table'] = 'efq_efq_views_test';
  $handler->display->display_options['sorts'][$field]['id'] = $field;
  $handler->display->display_options['sorts'][$field]['field'] = $field;
  $handler->display->display_options['sorts'][$field]['table'] = 'efq_efq_views_test';
  $asc_sorted_view = clone $view;
  $view
    ->execute();
  $this
    ->assertIdentical(array_keys($this
    ->getIds($view->result)), $this
    ->map($expected_result));
  $view = clone $asc_sorted_view;
  $handler = $view->display['default']->handler;
  $handler->display->display_options['sorts'][$field]['order'] = 'DESC';
  $view
    ->execute();
  $this
    ->assertIdentical(array_keys($this
    ->getIds($view->result)), $this
    ->map(array_reverse($expected_result)));
}