From dc4d421be78c471017fd8cf0d3b7986147844dab Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 22 May 2009 11:33:18 +0000 Subject: - Patch #396284 by Berdir, chx, jcfiala, csevb10 et al: make sure to order by table headers first, before ordering by other fields. --- modules/simpletest/tests/database_test.test | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'modules/simpletest/tests/database_test.test') diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test index 590e9c102..2fa7f6c8f 100644 --- a/modules/simpletest/tests/database_test.test +++ b/modules/simpletest/tests/database_test.test @@ -1769,6 +1769,32 @@ class DatabaseSelectTableSortDefaultTestCase extends DatabaseTestCase { $this->assertEqual($last->task, $sort['last'], t('Items appear in the correct order.')); } } + + /** + * Confirm that if a tablesort's orderByHeader is called before another orderBy, that the header happens first. + * + */ + function testTableSortQueryFirst() { + $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'), + // more elements here + + ); + + foreach ($sorts as $sort) { + $this->drupalGet('database_test/tablesort_first/', 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 sorting by @field @sort.', array('@field' => $sort['field'], '@sort' => $sort['sort']))); + $this->assertEqual($last->task, $sort['last'], t('Items appear in the correct order sorting by @field @sort.', array('@field' => $sort['field'], '@sort' => $sort['sort']))); + } + } } /** -- cgit v1.2.3