drupalCreateRole($this->getUserPermissions()); // Create a user model $user = array( 'name' => 'simpletestuser', 'mail' => 'simpletestuser@example.com', 'roles' => array( $role => $role ), 'pass' => 'simpletestpass', 'status' => 1, ); // Create a user from the model $this->privileged_user = user_save('', $user); // Add the raw password so we can log in $this->privileged_user->pass_raw = $user['pass']; // Log in !$this->drupalLogin($this->privileged_user); } /** * Automatically generates all module dependencies and enables them in order. * Also logs in a privileged user with the appropriate permissions for the * test. * * If you need to override this method to provide extra functionality, * please be sure to call parent::setUp so dependency resolution and * authentication still happen. */ public function setUp() { // Grab all the available modules $modules = module_rebuild_cache(); // Grab the module to test's dependencies $dependencies = $modules[$this->getModuleShortFormName()]->info['dependencies']; // Sort them so they're in the correct order to enable $dependencies = array_reverse($dependencies); // Add our module to the end $dependencies[] = $this->getModuleShortFormName(); // Enable the module's dependencies in order call_user_func_array('parent::setUp', $dependencies); // Authenticate the privileged user $this->createPrivilegedUser(); } }