public function ViewsHandlerSortTest::testStringOrdering
3.x views_handler_sort.test | public ViewsHandlerSortTest::testStringOrdering() |
Tests string ordering of the result set.
File
- tests/
handlers/ views_handler_sort.test, line 74 - Definition of ViewsHandlerSortTest.
Class
- ViewsHandlerSortTest
- Tests for core views_handler_sort handler.
Code
public function testStringOrdering() {
$view = $this->getBasicView();
// Change the ordering
$view->display['default']->handler->override_option('sorts', array(
'name' => array(
'order' => 'ASC',
'id' => 'name',
'table' => 'views_test',
'field' => 'name',
'relationship' => 'none',
),
));
// Execute the view.
$this->executeView($view);
// Verify the result.
$this->assertEqual(count($this->dataSet()), count($view->result), t('The number of returned rows match.'));
$this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'name'), array(
'views_test_name' => 'name',
'views_test_age' => 'age',
));
$view = $this->getBasicView();
// Reverse the ordering
$view->display['default']->handler->override_option('sorts', array(
'name' => array(
'order' => 'DESC',
'id' => 'name',
'table' => 'views_test',
'field' => 'name',
'relationship' => 'none',
),
));
// Execute the view.
$this->executeView($view);
// Verify the result.
$this->assertEqual(count($this->dataSet()), count($view->result), t('The number of returned rows match.'));
$this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'name', TRUE), array(
'views_test_name' => 'name',
'views_test_age' => 'age',
));
}