Index: modules/simpletest/drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.14 diff -u -r1.14 drupal_web_test_case.php --- modules/simpletest/drupal_web_test_case.php 5 Jun 2008 21:55:45 -0000 1.14 +++ modules/simpletest/drupal_web_test_case.php 5 Jun 2008 23:31:54 -0000 @@ -191,8 +191,7 @@ */ function drupalCreateUser($permissions = NULL) { // Create a role with the given permission set. - $rid = $this->_drupalCreateRole($permissions); - if (!$rid) { + if (!($rid = $this->_drupalCreateRole($permissions))) { return FALSE; } @@ -228,6 +227,10 @@ $permissions = array('access comments', 'access content', 'post comments', 'post comments without approval'); } + if (!$this->checkPermissions($permissions)) { + return FALSE; + } + // Create new role. $role_name = $this->randomName(); db_query("INSERT INTO {role} (name) VALUES ('%s')", $role_name); @@ -248,6 +251,25 @@ } /** + * Check to make sure that the array of permissions are valid. + * + * @param array $permissions Permissions to check. + * @return boolean Valid. + */ + private function checkPermissions(array $permissions) { + $available = array_keys(module_invoke_all('perm')); + + $valid = TRUE; + foreach ($permissions as $permission) { + if (!in_array($permission, $available)) { + $this->fail(t('Invalid permission %permission.', array('%permission' => $permission)), t('Role')); + $valid = FALSE; + } + } + return $valid; + } + + /** * Logs in a user with the internal browser. If already logged in then logs the current * user out before logging in the specified user. If no user is specified then a new * user will be created and logged in.