Index: CHANGELOG.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/autoassignrole/CHANGELOG.txt,v retrieving revision 1.7 diff -u -p -r1.7 CHANGELOG.txt --- CHANGELOG.txt 28 Oct 2010 17:03:28 -0000 1.7 +++ CHANGELOG.txt 28 Oct 2010 18:01:16 -0000 @@ -10,3 +10,4 @@ autoassignrole 7.0, xxxx-xx-xx (developm - [#944922] Administrator sets roles that will be visible to the end user. - [#944944] Administrator toggles letting user select multiple roles. - [#944974] Administrator sets the selection method of roles for an end user. +- [#944988] Administrator toggles sort order of roles exposed to an end user. Index: autoassignrole.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/autoassignrole/autoassignrole.admin.inc,v retrieving revision 1.6 diff -u -p -r1.6 autoassignrole.admin.inc --- autoassignrole.admin.inc 28 Oct 2010 17:03:29 -0000 1.6 +++ autoassignrole.admin.inc 28 Oct 2010 18:01:17 -0000 @@ -123,5 +123,16 @@ function autoassignrole_user_settings() '#options' => array(0 => t('Radio Buttons'), 1 => t('Selection Box'), 2 => t('Check Boxes')), ); + $form['autoassignrole_user_sort'] = array( + '#type' => 'radios', + '#title' => t('Sorting'), + '#default_value' => variable_get('autoassignrole_user_selection', 'SORT_ASC'), + '#description' => t('Default sort order of roles the user will see.'), + '#options' => array( + 'SORT_ASC' => t('Ascending'), + 'SORT_DESC' => t('Descending') + ), + ); + return system_settings_form($form); } Index: autoassignrole.test =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/autoassignrole/autoassignrole.test,v retrieving revision 1.7 diff -u -p -r1.7 autoassignrole.test --- autoassignrole.test 28 Oct 2010 17:03:29 -0000 1.7 +++ autoassignrole.test 28 Oct 2010 18:01:17 -0000 @@ -349,4 +349,50 @@ class AutoassignroleAdminSettingsTestCas 'autoassignrole_user_selection has been set to check box' ); } + +/** + * Test admin setting functionality for autoassignrole_user_selection. + * @see http://drupal.org/node/944988 + */ + function testAdminUserSortSettings() { + // Create a new user who can access the administration settings + $this->drupalLogin($this->admin_user); + + // Check that the user can see the admin settings page. + $this->drupalGet('admin/config/autoassignrole/user'); + $this->assertField( + 'autoassignrole_user_sort', + 'The autoassignrole_user_sort field is accessible.' + ); + + // Set autoassignrole_user_sort to radio SORT_ASC. + $edit['autoassignrole_user_sort'] = 'SORT_ASC'; + $this->drupalPost( + 'admin/config/autoassignrole/user', + $edit, + t('Save configuration') + ); + + // Verify autoassignrole_user_sort has set to SORT_ASC + $this->assertEqual( + variable_get('autoassignrole_user_sort', -1), + 'SORT_ASC', + 'autoassignrole_user_selection has been set to SORT_ASC' + ); + + // Set autoassignrole_user_sort to SORT_DESC. + $edit['autoassignrole_user_sort'] = 'SORT_DESC'; + $this->drupalPost( + 'admin/config/autoassignrole/user', + $edit, + t('Save configuration') + ); + + // Verify autoassignrole_user_sort has been set to 'SORT_DESC' + $this->assertEqual( + variable_get('autoassignrole_user_sort', -1), + 'SORT_DESC', + 'autoassignrole_user_sort has been set to SORT_DESC' + ); + } }