Index: modules/simpletest/tests/common.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v retrieving revision 1.4 diff -u -r1.4 common.test --- modules/simpletest/tests/common.test 29 Aug 2008 14:45:19 -0000 1.4 +++ modules/simpletest/tests/common.test 1 Sep 2008 19:13:46 -0000 @@ -144,3 +144,50 @@ $this->assertTitle(variable_get('site_name', 'Drupal'), t('Site title matches.')); } } + +/** + * Test tablesorting functions. + */ +class TablesortTestCase extends DrupalWebTestCase { + /** + * Implementation of getInfo(). + */ + function getInfo() { + return array( + 'name' => t('Drupal tablesort'), + 'description' => t("Performs tests on Drupal's tablesorting."), + 'group' => t('System'), + ); + } + + function testTablesortHeaderCellClass() { + $cell = array('field' => '', 'data' => '', 'class' => 'red'); + $header = array(); + $ts = array( + 'name' => '', + 'sort' => 'asc', + 'query_string' => '', + ); + $new_cell = tablesort_header($cell, $header, $ts); + $this->assertEqual($new_cell['class'], "red active"); + unset($cell['class']); + $new_cell = tablesort_header($cell, $header, $ts); + $this->assertEqual($new_cell['class'], "active"); + } + + function testTablesortHeaderQueryString() { + $cell = array('field' => '', 'data' => ''); + $header = array(); + $ts = array( + 'name' => '', + 'sort' => 'asc', + 'query_string' => 'name=value', + ); + $new_cell = tablesort_header($cell, $header, $ts); + $this->assertTrue(preg_match('/&name=value/', $new_cell['data']), t("Ampersand prepended")); + $old_data = str_replace("&name=value", "", $new_cell['data']); + $ts['query_string'] = ''; + $new_cell = tablesort_header($cell, $header, $ts); + $this->assertEqual($new_cell['data'], $old_data, t("Query string not appended")); + } +} \ No newline at end of file