function DatabaseSelectTableSortDefaultTestCase::testTableSortQuery in SimpleTest 7
Confirm that a tablesort query returns the correct results.
Note that we have to make an HTTP request to a test page handler because the pager depends on GET parameters.
File
- tests/
database_test.test, line 1990
Class
Code
function testTableSortQuery() {
$sorts = array(
array(
'field' => t('Task ID'),
'sort' => 'desc',
'first' => 'perform at superbowl',
'last' => 'eat',
),
array(
'field' => t('Task ID'),
'sort' => 'asc',
'first' => 'eat',
'last' => 'perform at superbowl',
),
array(
'field' => t('Task'),
'sort' => 'asc',
'first' => 'code',
'last' => 'sleep',
),
array(
'field' => t('Task'),
'sort' => 'desc',
'first' => 'sleep',
'last' => 'code',
),
);
foreach ($sorts as $sort) {
$this
->drupalGet('database_test/tablesort/', array(
'query' => array(
'order' => $sort['field'],
'sort' => $sort['sort'],
),
));
$data = json_decode($this
->drupalGetContent());
$first = array_shift($data->tasks);
$last = array_pop($data->tasks);
$this
->assertEqual($first->task, $sort['first'], t('Items appear in the correct order.'));
$this
->assertEqual($last->task, $sort['last'], t('Items appear in the correct order.'));
}
}