? simpletest ? simpletest-cleanup-user-237369-6.patch ? simpletest_1.0.1beta2.tar.gz Index: drupal_test_case.php =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/drupal_test_case.php,v retrieving revision 1.60 diff -u -p -r1.60 drupal_test_case.php --- drupal_test_case.php 22 Mar 2008 01:19:17 -0000 1.60 +++ drupal_test_case.php 22 Mar 2008 02:43:35 -0000 @@ -248,68 +248,75 @@ class DrupalTestCase extends UnitTestCas } } + /** + * Create a user with a given set of permissions. + * + * @param $permissions + * Array of permission names to assign to user. + * @return + * A fully loaded user object with pass_raw property, or FALSE if account + * creation fails. + */ + function drupalCreateUser($permissions = NULL) { + // Create a role with the given permission set. + $rid = $this->_drupalCreateRole($permissions); + if (!$rid) { + return FALSE; + } + + // Create a user assigned to that role. + $edit = array(); + $edit['name'] = $this->randomName(); + $edit['mail'] = $edit['name'] .'@example.com'; + $edit['roles'] = array($rid => $rid); + $edit['pass'] = user_password(); + $edit['status'] = 1; + + $account = user_save('', $edit); + + $this->assertTrue(!empty($account->uid), " [user] name: $edit[name] pass: $edit[pass] created"); + if (empty($account->uid)) { + return FALSE; + } + + // Add to list of users to remove when testing is completed. + $this->_cleanupUsers[] = $account->uid; + + // Add the raw password so that we can log in as this user. + $account->pass_raw = $edit['pass']; + return $account; + } /** - * Create a role / perm combination specified by permissions + * Internal helper function; Create a role with specified permissions. * - * @param array $permissions Array of the permission strings - * @return integer role-id + * @param $permissions + * Array of permission names to assign to role. + * @return integer + * Role ID of newly created role, or FALSE if role creation failed. */ - function drupalCreateRolePerm($permissions = NULL) { + private function _drupalCreateRole($permissions = NULL) { + // Generate string version of permissions list. if ($permissions === NULL) { - $permstring = 'access comments, access content, post comments, post comments without approval'; + $permission_string = 'access comments, access content, post comments, post comments without approval'; } else { - $permstring = implode(', ', $permissions); + $permission_string = implode(', ', $permissions); } - /* Create role */ + + // Create new role. $role_name = $this->randomName(); db_query("INSERT INTO {role} (name) VALUES ('%s')", $role_name); $role = db_fetch_object(db_query("SELECT * FROM {role} WHERE name = '%s'", $role_name)); - $this->assertTrue($role, " [role] created name: $role_name, id: " . (isset($role->rid) ? $role->rid : '-n/a-')); + $this->assertTrue($role, " [role] created name: $role_name, id: " . (isset($role->rid) ? $role->rid : t('-n/a-'))); if ($role && !empty($role->rid)) { - /* Create permissions */ - db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $role->rid, $permstring); - $this->assertTrue(db_affected_rows(), ' [role] created permissions: ' . $permstring); + // Assign permissions to role and mark it for clean-up. + db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $role->rid, $permission_string); + $this->assertTrue(db_affected_rows(), ' [role] created permissions: ' . $permission_string); $this->_cleanupRoles[] = $role->rid; return $role->rid; } else { - return false; - } - } - - /** - * Creates a user / role / permissions combination specified by permissions - * - * @param array $permissions Array of the permission strings - * @return array/boolean false if fails. fully loaded user object with added pass_raw property - */ - function drupalCreateUserRolePerm($permissions = NULL) { - /* Create role */ - $rid = $this->drupalCreateRolePerm($permissions); - if (!$rid) { - return FALSE; - } - /* Create user */ - $ua = array(); - $ua['name'] = $this->randomName(); - $ua['mail'] = $ua['name'] . '@example.com'; - $ua['roles'] = array($rid=>$rid); - $ua['pass'] = user_password(); - $ua['status'] = 1; - - $u = user_save('', $ua); - - $this->assertTrue(!empty($u->uid), " [user] name: $ua[name] pass: $ua[pass] created"); - if (empty($u->uid)) { return FALSE; } - - /* Add to cleanup list */ - $this->_cleanupUsers[] = $u->uid; - - /* Add the raw password */ - $u->pass_raw = $ua['pass']; - return $u; } /** @@ -318,13 +325,13 @@ class DrupalTestCase extends UnitTestCas * @param object user object with pass_raw property! * @param $submit value of submit button on log in form */ - function drupalLoginUser($user = NULL, $submit = 'Log in') { + function drupalLogin($user = NULL, $submit = 'Log in') { if ($this->_logged_in) { - $this->drupalGet('logout'); + $this->drupalLogout(); } if (!isset($user)) { - $user = $this->drupalCreateUserRolePerm(); + $user = $this->_drupalCreateRole(); } $edit = array('name' => $user->name, 'pass' => $user->pass_raw); @@ -338,6 +345,18 @@ class DrupalTestCase extends UnitTestCas return $user; } + + /* + * Logs a user out of the internal browser, then check the login page to confirm logout. + */ + function drupalLogout() { + //make a request to the logout page + $this->drupalGet('logout'); + //load the user page, the idea being if you were properly logged out you should be seeing a login screen + $this->drupalGet('user'); + $this->assertField("name"); + $this->assertField("pass"); + } /** * tearDown implementation, setting back switched modules etc Index: tests/functional/aggregator.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/aggregator.test,v retrieving revision 1.2 diff -u -p -r1.2 aggregator.test --- tests/functional/aggregator.test 22 Mar 2008 01:19:17 -0000 1.2 +++ tests/functional/aggregator.test 22 Mar 2008 02:43:35 -0000 @@ -7,8 +7,8 @@ class DrupalAggregatorTestCase extends D function setUp() { parent::setUp(); $this->drupalModuleEnable('aggregator'); - $web_user = $this->drupalCreateUserRolePerm(array('administer news feeds', 'access news feeds')); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('administer news feeds', 'access news feeds')); + $this->drupalLogin($web_user); } /** Index: tests/functional/block.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/block.test,v retrieving revision 1.4 diff -u -p -r1.4 block.test --- tests/functional/block.test 22 Mar 2008 01:19:17 -0000 1.4 +++ tests/functional/block.test 22 Mar 2008 02:43:35 -0000 @@ -17,8 +17,8 @@ class BlockModuleTestCase extends Drupal parent::setUp(); // Create and login user - $admin_user = $this->drupalCreateUserRolePerm(array('administer blocks')); - $this->drupalLoginUser($admin_user); + $admin_user = $this->drupalCreateUser(array('administer blocks')); + $this->drupalLogin($admin_user); } /** Index: tests/functional/blogapi.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/blogapi.test,v retrieving revision 1.3 diff -u -p -r1.3 blogapi.test --- tests/functional/blogapi.test 22 Mar 2008 01:19:17 -0000 1.3 +++ tests/functional/blogapi.test 22 Mar 2008 02:43:35 -0000 @@ -20,8 +20,8 @@ class BlogAPIModuleTestCase extends Drup function test_blog_API() { // Create admin user and taxononmy for later use. - $admin_user = $this->drupalCreateUserRolePerm(array('administer taxonomy')); - $this->drupalLoginUser($admin_user); + $admin_user = $this->drupalCreateUser(array('administer taxonomy')); + $this->drupalLogin($admin_user); $vid = $this->add_vocabulary('simpletest_vocab'); @@ -30,8 +30,8 @@ class BlogAPIModuleTestCase extends Drup $this->drupalGet('logout'); // Create user. - $web_user = $this->drupalCreateUserRolePerm(array('create blog entries', 'delete own blog entries', 'edit own blog entries', 'administer content with blog api')); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('create blog entries', 'delete own blog entries', 'edit own blog entries', 'administer content with blog api')); + $this->drupalLogin($web_user); // Init common variables. $local = url('xmlrpc.php', array('absolute' => TRUE)); @@ -106,7 +106,7 @@ class BlogAPIModuleTestCase extends Drup $this->drupalGet('logout'); // Remove taxonmy vocab. - $this->drupalLoginUser($admin_user); + $this->drupalLogin($admin_user); $this->drupalPost('admin/content/taxonomy/edit/vocabulary/'. $vid, array(), t('Delete')); $this->drupalPost(NULL, array(), t('Delete')); Index: tests/functional/book.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/book.test,v retrieving revision 1.3 diff -u -p -r1.3 book.test --- tests/functional/book.test 22 Mar 2008 01:19:17 -0000 1.3 +++ tests/functional/book.test 22 Mar 2008 02:43:35 -0000 @@ -23,11 +23,11 @@ class BookModuleTestCase extends DrupalT */ function testBook() { // create users - $book_author = $this->drupalCreateUserRolePerm(array('create new books', 'create book content', 'add content to books')); - $web_user = $this->drupalCreateUserRolePerm(array('access printer-friendly version')); + $book_author = $this->drupalCreateUser(array('create new books', 'create book content', 'add content to books')); + $web_user = $this->drupalCreateUser(array('access printer-friendly version')); // create new book - $this->drupalLoginUser($book_author); + $this->drupalLogin($book_author); $this->book = $this->createBookNode('new'); $book = $this->book; @@ -51,7 +51,7 @@ class BookModuleTestCase extends DrupalT $this->drupalGet('logout'); // check to make sure that book pages display properly - $this->drupalLoginUser($web_user); + $this->drupalLogin($web_user); $this->checkBookNode($book, array($nodes[0], $nodes[3], $nodes[4]), false, false, $nodes[0]); $this->checkBookNode($nodes[0], array($nodes[1], $nodes[2]), $book, $book, $nodes[1]); Index: tests/functional/comment.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/comment.test,v retrieving revision 1.6 diff -u -p -r1.6 comment.test --- tests/functional/comment.test 22 Mar 2008 01:19:17 -0000 1.6 +++ tests/functional/comment.test 22 Mar 2008 02:43:36 -0000 @@ -26,10 +26,10 @@ class CommentModuleTestCase extends Drup $this->drupalModuleEnable('comment'); // Create users. - $this->admin_user = $this->drupalCreateUserRolePerm(array('administer content types', 'administer comments', 'administer permissions')); - $this->web_user = $this->drupalCreateUserRolePerm(array('access comments', 'post comments', 'create story content')); + $this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer permissions')); + $this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'create story content')); - $this->drupalLoginUser($this->web_user); + $this->drupalLogin($this->web_user); $this->node = $this->drupalCreateNode(array('type' => 'story')); $this->assertTrue($this->node, 'Story node created.'); $this->drupalGet('logout'); @@ -40,25 +40,25 @@ class CommentModuleTestCase extends Drup */ function testCommentInterface() { // Set comments to not have subject. - $this->drupalLoginUser($this->admin_user); + $this->drupalLogin($this->admin_user); $this->set_comment_preview(TRUE); $this->set_comment_subject(FALSE); $this->drupalGet('logout'); // Post comment without subject - $this->drupalLoginUser($this->web_user); + $this->drupalLogin($this->web_user); $this->drupalGet('comment/reply/'. $this->node->nid); $this->assertNoPattern('/(input)(.*?)(name="subject")/', 'Subject field not found.'); // Set comments to have subject and preview to required. $this->drupalGet('logout'); - $this->drupalLoginUser($this->admin_user); + $this->drupalLogin($this->admin_user); $this->set_comment_subject(true); $this->set_comment_preview(true); $this->drupalGet('logout'); // Create comment that requires preview. - $this->drupalLoginUser($this->web_user); + $this->drupalLogin($this->web_user); $comment = $this->post_comment($this->node, $this->randomName(), $this->randomName()); $this->assertTrue($this->comment_exists($comment), 'Comment found.'); @@ -74,7 +74,7 @@ class CommentModuleTestCase extends Drup // Delete comment and make sure that reply is also removed. $this->drupalGet('logout'); - $this->drupalLoginUser($this->admin_user); + $this->drupalLogin($this->admin_user); $this->delete_comment($comment); $this->drupalGet('node/'. $this->node->nid); @@ -87,19 +87,19 @@ class CommentModuleTestCase extends Drup */ function testFormOnPage() { // Enabled comment form on node page. - $this->drupalLoginUser($this->admin_user); + $this->drupalLogin($this->admin_user); $this->set_comment_form(TRUE); $this->drupalGet('logout'); // Submit comment through node form. - $this->drupalLoginUser($this->web_user); + $this->drupalLogin($this->web_user); $this->drupalGet('node/'. $this->node->nid); $form_comment = $this->post_comment(NULL, $this->randomName(), $this->randomName()); $this->assertTrue($this->comment_exists($form_comment), 'Form comment found.'); // Disable comment form on node page. $this->drupalGet('logout'); - $this->drupalLoginUser($this->admin_user); + $this->drupalLogin($this->admin_user); $this->set_comment_form(FALSE); } @@ -107,7 +107,7 @@ class CommentModuleTestCase extends Drup * Test anonymous comment functionality. */ function testAnonymous() { - $this->drupalLoginUser($this->admin_user); + $this->drupalLogin($this->admin_user); // Enabled anonymous user comments. $this->set_anonymous_user_comment(TRUE, TRUE); $this->set_comment_anonymous('0'); // Ensure that doesn't require contact info. @@ -118,7 +118,7 @@ class CommentModuleTestCase extends Drup $this->assertTrue($this->comment_exists($anonymous_comment1), 'Anonymous comment without contact info found.'); // Allow contact info. - $this->drupalLoginUser($this->admin_user); + $this->drupalLogin($this->admin_user); $this->set_comment_anonymous('1'); $this->drupalGet('logout'); @@ -130,7 +130,7 @@ class CommentModuleTestCase extends Drup $this->assertTrue($this->comment_exists($anonymous_comment2), 'Anonymous comment with contact info (optional) found.'); // Require contact info. - $this->drupalLoginUser($this->admin_user); + $this->drupalLogin($this->admin_user); $this->set_comment_anonymous('2'); $this->drupalGet('logout'); @@ -147,7 +147,7 @@ class CommentModuleTestCase extends Drup $this->assertTrue($this->comment_exists($anonymous_comment3), 'Anonymous comment with contact info (required) found.'); // Unpublish comment. - $this->drupalLoginUser($this->admin_user); + $this->drupalLogin($this->admin_user); $this->perform_comment_operation($anonymous_comment3, 'unpublish'); $this->drupalGet('admin/content/comment/approval'); @@ -177,7 +177,7 @@ class CommentModuleTestCase extends Drup $this->assertText(t('Your comment has been queued for moderation by site administrators and will be published after approval.'), 'Comment requires approval.'); // Get unaproved comment id. - $this->drupalLoginUser($this->admin_user); + $this->drupalLogin($this->admin_user); $anonymous_comment4 = $this->get_unaproved_comment($subject); $anonymous_comment4 = (object) array('id' => $anonymous_comment4, 'subject' => $subject, 'comment' => $body); $this->drupalGet('logout'); @@ -185,7 +185,7 @@ class CommentModuleTestCase extends Drup $this->assertFalse($this->comment_exists($anonymous_comment4), 'Anonymous comment was not published.'); // Approve comment. - $this->drupalLoginUser($this->admin_user); + $this->drupalLogin($this->admin_user); $this->perform_comment_operation($anonymous_comment4, 'publish', TRUE); $this->drupalGet('logout'); @@ -193,7 +193,7 @@ class CommentModuleTestCase extends Drup $this->assertTrue($this->comment_exists($anonymous_comment4), 'Anonymous comment visible.'); // Reset. - $this->drupalLoginUser($this->admin_user); + $this->drupalLogin($this->admin_user); $this->set_anonymous_user_comment(FALSE, FALSE); } Index: tests/functional/contact.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/contact.test,v retrieving revision 1.4 diff -u -p -r1.4 contact.test --- tests/functional/contact.test 22 Mar 2008 01:19:17 -0000 1.4 +++ tests/functional/contact.test 22 Mar 2008 02:43:36 -0000 @@ -24,8 +24,8 @@ class ContactModuleTestCase extends Drup */ function test_site_wide_contact() { // Create and login administative user. - $admin_user = $this->drupalCreateUserRolePerm(array('administer site-wide contact form', 'administer permissions')); - $this->drupalLoginUser($admin_user); + $admin_user = $this->drupalCreateUser(array('administer site-wide contact form', 'administer permissions')); + $this->drupalLogin($admin_user); // Set settings. $edit = array(); @@ -70,7 +70,7 @@ class ContactModuleTestCase extends Drup $this->assertResponse(403, 'Access denied to anonymous user without permission.'); // Give anonymous user permission and see that page is viewable. - $this->drupalLoginUser($admin_user); + $this->drupalLogin($admin_user); $this->set_permission('anonymous user', array('access site-wide contact form' => TRUE)); $this->drupalGet('logout'); @@ -107,7 +107,7 @@ class ContactModuleTestCase extends Drup $this->assertWantedRaw(t('You cannot send more than %number messages per hour. Please try again later.', array('%number' => $edit['contact_hourly_threshold'])), 'Message threshold reached.'); // Delete created categories. - $this->drupalLoginUser($admin_user); + $this->drupalLogin($admin_user); $this->delete_categories(); } @@ -115,8 +115,8 @@ class ContactModuleTestCase extends Drup * Test personal contact form. */ function atest_personal_contact() { - $admin_user = $this->drupalCreateUserRolePerm(array('administer site-wide contact form')); - $this->drupalLoginUser($admin_user); + $admin_user = $this->drupalCreateUser(array('administer site-wide contact form')); + $this->drupalLogin($admin_user); // Enable the personal contact form. $edit = array(); @@ -129,10 +129,10 @@ class ContactModuleTestCase extends Drup $this->reload_variables(); // Create web users and attempt to use personal contact forms with default set to true. - $web_user1 = $this->drupalCreateUserRolePerm(array()); - $web_user2 = $this->drupalCreateUserRolePerm(array()); + $web_user1 = $this->drupalCreateUser(array()); + $web_user2 = $this->drupalCreateUser(array()); - $this->drupalLoginUser($web_user1); + $this->drupalLogin($web_user1); $this->drupalGet('user/'. $web_user2->uid .'/contact'); $this->assertResponse(array(200), 'Access to personal contact form granted.'); @@ -145,7 +145,7 @@ class ContactModuleTestCase extends Drup $this->drupalGet('logout'); - $this->drupalLoginUser($admin_user); + $this->drupalLogin($admin_user); // Disable the personal contact form. $edit = array(); @@ -158,10 +158,10 @@ class ContactModuleTestCase extends Drup $this->reload_variables(); // Create web users and attempt to use personal contact forms with default set to false. - $web_user3 = $this->drupalCreateUserRolePerm(array()); - $web_user4 = $this->drupalCreateUserRolePerm(array()); + $web_user3 = $this->drupalCreateUser(array()); + $web_user4 = $this->drupalCreateUser(array()); - $this->drupalLoginUser($web_user3); + $this->drupalLogin($web_user3); $this->drupalGet('user/'. $web_user4->uid .'/contact'); $this->assertResponse(array(403), 'Access to personal contact form denied.'); Index: tests/functional/filter.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/filter.test,v retrieving revision 1.3 diff -u -p -r1.3 filter.test --- tests/functional/filter.test 22 Mar 2008 01:19:17 -0000 1.3 +++ tests/functional/filter.test 22 Mar 2008 02:43:36 -0000 @@ -26,10 +26,10 @@ class FilterModuleTestCase extends Drupa $second_filter = ($version_five ? 2 : 1); // line filter // Create users. - $admin_user = $this->drupalCreateUserRolePerm(array('administer filters')); - $web_user = $this->drupalCreateUserRolePerm(array('create page content')); + $admin_user = $this->drupalCreateUser(array('administer filters')); + $web_user = $this->drupalCreateUser(array('create page content')); - $this->drupalLoginUser($admin_user); + $this->drupalLogin($admin_user); list($filtered, $full) = $this->check_filter_formats(); @@ -110,7 +110,7 @@ class FilterModuleTestCase extends Drupa // Switch user. $this->drupalGet('logout'); - $this->drupalLoginUser($web_user); + $this->drupalLogin($web_user); $this->drupalGet('node/add/page'); $this->assert_format($full, 'Full HTML filter accessible.'); @@ -135,7 +135,7 @@ class FilterModuleTestCase extends Drupa // Switch user. $this->drupalGet('logout'); - $this->drupalLoginUser($admin_user); + $this->drupalLogin($admin_user); // Clean up. // Allowed tags Index: tests/functional/forum.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/forum.test,v retrieving revision 1.5 diff -u -p -r1.5 forum.test --- tests/functional/forum.test 22 Mar 2008 01:19:17 -0000 1.5 +++ tests/functional/forum.test 22 Mar 2008 02:43:36 -0000 @@ -81,11 +81,11 @@ class AddForumTest extends DrupalForumTe function testAddForumContainer() { // Attempt to create a forum container - $web_user = $this->drupalCreateUserRolePerm(array( + $web_user = $this->drupalCreateUser(array( 'access administration pages', 'administer forums', )); - $this->drupalLoginUser($web_user); + $this->drupalLogin($web_user); // Create the container, all the assertions are handled in the function $container = $this->createForumContainer(); @@ -97,11 +97,11 @@ class AddForumTest extends DrupalForumTe function testAddForum() { // Attempt to create a forum - $web_user = $this->drupalCreateUserRolePerm(array( + $web_user = $this->drupalCreateUser(array( 'access administration pages', 'administer forums', )); - $this->drupalLoginUser($web_user); + $this->drupalLogin($web_user); // Create the forum, all assertions are handled in the function $forum = $this->createForum(); @@ -122,11 +122,11 @@ class EditForumTaxonomyTest extends Drup function testEditForumTaxonomy() { // Attempt to edit the forum taxonomy - $web_user = $this->drupalCreateUserRolePerm(array( + $web_user = $this->drupalCreateUser(array( 'access administration pages', 'administer taxonomy', )); - $this->drupalLoginUser($web_user); + $this->drupalLogin($web_user); $vid = variable_get('forum_nav_vocabulary', ''); $original_settings = taxonomy_vocabulary_load($vid); @@ -171,12 +171,12 @@ class AddTopicToForum extends DrupalForu function testAddTopicToForum() { // Attempt to create a forum - $web_user = $this->drupalCreateUserRolePerm(array( + $web_user = $this->drupalCreateUser(array( 'access administration pages', 'administer forums', 'create forum content' )); - $this->drupalLoginUser($web_user); + $this->drupalLogin($web_user); // Generate a forum $forum = $this->createForum(); @@ -214,12 +214,12 @@ class AddTopicToForum extends DrupalForu function testAddTopicToContainer() { // Attempt to create a forum container - $web_user = $this->drupalCreateUserRolePerm(array( + $web_user = $this->drupalCreateUser(array( 'access administration pages', 'administer forums', 'create forum content' )); - $this->drupalLoginUser($web_user); + $this->drupalLogin($web_user); // Create the container $container = $this->createForumContainer(); @@ -251,13 +251,13 @@ class AddTopicToForum extends DrupalForu function testMoveTopicToForum() { // Attempt to create a forum - $web_user = $this->drupalCreateUserRolePerm(array( + $web_user = $this->drupalCreateUser(array( 'access administration pages', 'administer forums', 'create forum content', 'edit any forum content' )); - $this->drupalLoginUser($web_user); + $this->drupalLogin($web_user); $forum1 = $this->createForum(); $forum2 = $this->createForum(); @@ -308,13 +308,13 @@ class AddTopicToForum extends DrupalForu function testMoveTopicWithCopyToForum() { // Attempt to create a forum - $web_user = $this->drupalCreateUserRolePerm(array( + $web_user = $this->drupalCreateUser(array( 'access administration pages', 'administer forums', 'create forum content', 'edit any forum content' )); - $this->drupalLoginUser($web_user); + $this->drupalLogin($web_user); $forum1 = $this->createForum(); $forum2 = $this->createForum(); Index: tests/functional/locale.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/locale.test,v retrieving revision 1.4 diff -u -p -r1.4 locale.test --- tests/functional/locale.test 22 Mar 2008 01:19:17 -0000 1.4 +++ tests/functional/locale.test 22 Mar 2008 02:43:36 -0000 @@ -23,9 +23,9 @@ class LocaleModuleTest extends DrupalTes global $base_url; // User to add and remove language. - $admin_user = $this->drupalCreateUserRolePerm(array('administer languages', 'access administration pages')); + $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages')); // User to translate and delete string. - $translate_user = $this->drupalCreateUserRolePerm(array('translate interface', 'access administration pages')); + $translate_user = $this->drupalCreateUser(array('translate interface', 'access administration pages')); // Code for the language. $langcode = str_replace('simpletest_', 'si-', $this->randomName(6)); // The English name for the language. This will be translated. @@ -41,7 +41,7 @@ class LocaleModuleTest extends DrupalTes $translation = $this->randomName(16); // Add language. - $this->drupalLoginUser($admin_user); + $this->drupalLogin($admin_user); $edit = array ( 'langcode' => $langcode, 'name' => $name, @@ -63,7 +63,7 @@ class LocaleModuleTest extends DrupalTes $this->drupalGet('logout'); // Search for the name and translate it. - $this->drupalLoginUser($translate_user); + $this->drupalLogin($translate_user); $search = array ( 'string' => $name, 'language' => 'all', @@ -95,7 +95,7 @@ class LocaleModuleTest extends DrupalTes $this->drupalGet('logout'); // Delete the language - $this->drupalLoginUser($admin_user); + $this->drupalLogin($admin_user); $path = 'admin/settings/language/delete/'. $langcode; // This a confirm form, we do not need any fields changed. $this->drupalPost($path, array(), t('Delete')); @@ -109,7 +109,7 @@ class LocaleModuleTest extends DrupalTes $this->drupalGet('logout'); // Delete the name string. - $this->drupalLoginUser($translate_user); + $this->drupalLogin($translate_user); $this->drupalGet('admin/build/translate/delete/'. $lid); $this->assertText(t('The string has been removed.'), 'The string has been removed message.'); $this->drupalPost('admin/build/translate/search', $search, t('Search')); Index: tests/functional/menu.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/menu.test,v retrieving revision 1.3 diff -u -p -r1.3 menu.test --- tests/functional/menu.test 22 Mar 2008 01:19:17 -0000 1.3 +++ tests/functional/menu.test 22 Mar 2008 02:43:37 -0000 @@ -22,8 +22,8 @@ class MenuModuleTestCase extends Drupal function testCreateCheckDelete() { - $web_user = $this->drupalCreateUserRolePerm(array('access content', 'administer menu', 'access administration pages',)); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('access content', 'administer menu', 'access administration pages',)); + $this->drupalLogin($web_user); $mlid1 = $this->uiCreateLink(); $mlid2 = $this->uiCreateLink($mlid1); @@ -105,8 +105,8 @@ class MenuModuleCustomMenuTest extends M } function testCreateCheckDelete() { - $web_user = $this->drupalCreateUserRolePerm(array('access content', 'administer menu', 'access administration pages',)); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('access content', 'administer menu', 'access administration pages',)); + $this->drupalLogin($web_user); $this->drupalGet('admin/build/menu/add'); $name = substr(md5($this->randomName(16)), 0, 20); @@ -156,8 +156,8 @@ class MenuModuleEnable extends DrupalTes } function testMenuModuleEnable() { - $web_user = $this->drupalCreateUserRolePerm(array('administer menu')); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('administer menu')); + $this->drupalLogin($web_user); $this->drupalGet('admin/build/menu-customize/navigation'); $this->clickLink(t('edit'), 0); $url = $this->getUrl(); @@ -200,8 +200,8 @@ class MenuModuleReset extends DrupalTest } function testMenuModuleReset() {; - $web_user = $this->drupalCreateUserRolePerm(array('administer menu')); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('administer menu')); + $this->drupalLogin($web_user); $form_state = array(); $menu['menu_name'] = 'navigation'; require_once drupal_get_path('module', 'menu') .'/menu.admin.inc'; @@ -261,8 +261,8 @@ class MenuModuleInvalidPath extends Drup } function testMenuModuleInvalidPath() { - $web_user = $this->drupalCreateUserRolePerm(array('administer menu')); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('administer menu')); + $this->drupalLogin($web_user); foreach (array('-&-', 'admin/user/permissions') as $invalid_path) { $edit = array ( 'menu[link_path]' => $invalid_path, Index: tests/functional/node.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/node.test,v retrieving revision 1.5 diff -u -p -r1.5 node.test --- tests/functional/node.test 22 Mar 2008 01:19:17 -0000 1.5 +++ tests/functional/node.test 22 Mar 2008 02:43:37 -0000 @@ -50,8 +50,8 @@ class NodeRevisionsTest extends DrupalTe function testNodeRevisions() { extract( $this->prepareRevisions() ); - $test_user = $this->drupalCreateUserRolePerm(array('view revisions')); - $this->drupalLoginUser($test_user); + $test_user = $this->drupalCreateUser(array('view revisions')); + $this->drupalLogin($test_user); $this->drupalGet("node/$node->nid/revisions/$vid/view"); $this->assertText($text, 'Check to make sure correct revision text appears on "view revisions" page.'); @@ -64,8 +64,8 @@ class NodeRevisionsTest extends DrupalTe function testLogMessage() { extract( $this->prepareRevisions(TRUE) ); - $test_user = $this->drupalCreateUserRolePerm(array('view revisions')); - $this->drupalLoginUser($test_user); + $test_user = $this->drupalCreateUser(array('view revisions')); + $this->drupalLogin($test_user); $this->drupalGet("node/$node->nid/revisions"); $this->assertText($log, 'Check to make sure log message is properly displayed.'); @@ -78,8 +78,8 @@ class NodeRevisionsTest extends DrupalTe function testRevisionRevert() { extract( $this->prepareRevisions() ); - $test_user = $this->drupalCreateUserRolePerm(array('revert revisions', 'edit any page content')); - $this->drupalLoginUser($test_user); + $test_user = $this->drupalCreateUser(array('revert revisions', 'edit any page content')); + $this->drupalLogin($test_user); $this->drupalPost("node/$node->nid/revisions/$vid/revert", array(), t('Revert')); $newnode = node_load($node->nid); $this->assertTrue(($text == $newnode->body), 'Check to make sure reversions occur properly'); @@ -93,8 +93,8 @@ class NodeRevisionsTest extends DrupalTe function testRevisionDelete() { extract( $this->prepareRevisions() ); - $test_user = $this->drupalCreateUserRolePerm(array('delete revisions', 'delete any page content')); - $this->drupalLoginUser($test_user); + $test_user = $this->drupalCreateUser(array('delete revisions', 'delete any page content')); + $this->drupalLogin($test_user); $this->drupalPost("node/$node->nid/revisions/$vid/delete", array(), t('Delete')); $this->assertTrue(db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d and VID = %d', $node->nid, $vid)) == 0, 'Check to make sure revisions delete properly'); $this->cleanup($node->nid); @@ -274,8 +274,8 @@ class StoryEditTest extends DrupalTestCa /* Prepare settings */ $this->drupalVariableSet('node_options_story', array('status', 'promote')); /* Prepare a user to do the stuff */ - $web_user = $this->drupalCreateUserRolePerm(array('edit own story content', 'create story content')); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('edit own story content', 'create story content')); + $this->drupalLogin($web_user); $edit = array( 'title' => '!SimpleTest! test title' . $this->randomName(20), 'body' => '!SimpleTest! test body' . $this->randomName(200), @@ -323,8 +323,8 @@ class StoryPreviewTest extends DrupalTes /* Prepare settings */ $this->drupalVariableSet('node_options_story', array('status', 'promote')); /* Prepare a user to do the stuff */ - $web_user = $this->drupalCreateUserRolePerm(array('edit own story content', 'create story content')); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('edit own story content', 'create story content')); + $this->drupalLogin($web_user); $edit = array( 'title'=>'!SimpleTest! title' . $this->randomName(20), @@ -360,8 +360,8 @@ class PageCreationTest extends DrupalTe $this->drupalVariableSet('node_options_page', array('status', 'promote')); /* Prepare a user to do the stuff */ - $web_user = $this->drupalCreateUserRolePerm(array('edit own page content', 'create page content')); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('edit own page content', 'create page content')); + $this->drupalLogin($web_user); $edit = array(); $edit['title'] = '!SimpleTest test node! ' . $this->randomName(10); @@ -401,13 +401,13 @@ class PageViewTest extends DrupalTestCas $this->assertResponse(403); /* Prepare a user to request the node view */ - $test_user = $this->drupalCreateUserRolePerm(array('access content')); - $this->drupalLoginUser($test_user); + $test_user = $this->drupalCreateUser(array('access content')); + $this->drupalLogin($test_user); $html = $this->drupalGet("node/$node->nid/edit"); $this->assertResponse(403); - $test_user = $this->drupalCreateUserRolePerm(array('administer nodes')); + $test_user = $this->drupalCreateUser(array('administer nodes')); //TODO: Add edit page attempt with administer nodes user node_delete($node->nid); } Index: tests/functional/path.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/path.test,v retrieving revision 1.5 diff -u -p -r1.5 path.test --- tests/functional/path.test 22 Mar 2008 01:19:17 -0000 1.5 +++ tests/functional/path.test 22 Mar 2008 02:43:37 -0000 @@ -19,8 +19,8 @@ class PathModuleTestCase extends DrupalT $this->drupalModuleEnable('path'); // create and login user - $web_user = $this->drupalCreateUserRolePerm(array('edit own page content', 'create page content', 'administer url aliases', 'create url aliases')); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('edit own page content', 'create page content', 'administer url aliases', 'create url aliases')); + $this->drupalLogin($web_user); } /** Index: tests/functional/poll.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/poll.test,v retrieving revision 1.5 diff -u -p -r1.5 poll.test --- tests/functional/poll.test 22 Mar 2008 01:19:17 -0000 1.5 +++ tests/functional/poll.test 22 Mar 2008 02:43:37 -0000 @@ -5,8 +5,8 @@ class PollTests extends DrupalTestCase { function pollCreate($standalone = TRUE) { $this->assertTrue(TRUE, 'Poll create' . $standalone); - $web_user = $this->drupalCreateUserRolePerm(array('create poll content', 'access content')); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('create poll content', 'access content')); + $this->drupalLogin($web_user); $title = $this->randomName(); $edit = array ( 'title' => $title, @@ -80,8 +80,8 @@ class PollVoteTest extends PollTests { function testPollVote() { $this->pollCreate(FALSE); $this->drupalGet('logout'); - $web_user = $this->drupalCreateUserRolePerm(array('cancel own vote', 'inspect all votes', 'vote on polls', 'access content')); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('cancel own vote', 'inspect all votes', 'vote on polls', 'access content')); + $this->drupalLogin($web_user); $edit = array ( 'choice' => '1', ); Index: tests/functional/system.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/system.test,v retrieving revision 1.5 diff -u -p -r1.5 system.test --- tests/functional/system.test 22 Mar 2008 01:19:17 -0000 1.5 +++ tests/functional/system.test 22 Mar 2008 02:43:37 -0000 @@ -45,11 +45,11 @@ class EnableCoreModuleTest extends Drupa // Get a list of the currently enabled modules $enabled_modules = module_list(true, false); - $web_user = $this->drupalCreateUserRolePerm(array ( + $web_user = $this->drupalCreateUser(array ( 'access administration pages', 'administer site configuration', )); - $this->drupalLoginUser($web_user); + $this->drupalLogin($web_user); $edit = array(); // We temporarily disable any modules we're testing so that we can re-enable them for testing @@ -111,11 +111,11 @@ class EnableModuleWithoutDependencyTest } // Attempt to enable forum module, which should fail because comment and taxonomy are not enabled - $web_user = $this->drupalCreateUserRolePerm(array ( + $web_user = $this->drupalCreateUser(array ( 'access administration pages', 'administer site configuration', )); - $this->drupalLoginUser($web_user); + $this->drupalLogin($web_user); $edit = array ( 'status[forum]' => 'forum', @@ -183,11 +183,11 @@ class DisableUninstallCoreModuleTest ext module_enable($modules_to_test); drupal_install_modules($modules_to_test); - $web_user = $this->drupalCreateUserRolePerm(array ( + $web_user = $this->drupalCreateUser(array ( 'access administration pages', 'administer site configuration', )); - $this->drupalLoginUser($web_user); + $this->drupalLogin($web_user); // Disable/uninstall the given modules: we keep every other module enabled // We do this loop because for each level of dependency, we need one more request Index: tests/functional/taxonomy.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/taxonomy.test,v retrieving revision 1.5 diff -u -p -r1.5 taxonomy.test --- tests/functional/taxonomy.test 22 Mar 2008 01:19:17 -0000 1.5 +++ tests/functional/taxonomy.test 22 Mar 2008 02:43:37 -0000 @@ -279,8 +279,8 @@ class TaxonomyTestNodeApi extends Drupal // create test user and login $perm = array('access content', 'create story content', 'edit own story content', 'delete own story content'); - $account = $this->drupalCreateUserRolePerm($perm); - $this->drupalLoginUser($account); + $account = $this->drupalCreateUser($perm); + $this->drupalLogin($account); // why is this printing out the user profile page? // go to node/add/story Index: tests/functional/translation.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/translation.test,v retrieving revision 1.4 diff -u -p -r1.4 translation.test --- tests/functional/translation.test 22 Mar 2008 01:19:17 -0000 1.4 +++ tests/functional/translation.test 22 Mar 2008 02:43:37 -0000 @@ -22,10 +22,10 @@ class TranslationModuleTestCase extends function test_content_translation() { // Setup users. - $admin_user = $this->drupalCreateUserRolePerm(array('administer languages', 'administer content types', 'access administration pages')); - $translator = $this->drupalCreateUserRolePerm(array('create story content', 'edit own story content', 'translate content')); + $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages')); + $translator = $this->drupalCreateUser(array('create story content', 'edit own story content', 'translate content')); - $this->drupalLoginUser($admin_user); + $this->drupalLogin($admin_user); // Add languages. $this->add_language('en'); @@ -36,7 +36,7 @@ class TranslationModuleTestCase extends $this->assertWantedRaw(t('The content type %type has been updated.', array('%type' => 'Story')), 'Story content type has been updated.'); $this->drupalGet('logout'); - $this->drupalLoginUser($translator); + $this->drupalLogin($translator); // Create story in English. $node_title = 'Test Translation '. $this->randomName(); Index: tests/functional/trigger.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/trigger.test,v retrieving revision 1.4 diff -u -p -r1.4 trigger.test --- tests/functional/trigger.test 22 Mar 2008 01:19:17 -0000 1.4 +++ tests/functional/trigger.test 22 Mar 2008 02:43:37 -0000 @@ -37,8 +37,8 @@ class ActionsContentTest extends Drupal // Test 1: Assign an action to a trigger, then pull the trigger, and make sure the actions fire. (Wow, those metaphors work out nicely). - $test_user = $this->drupalCreateUserRolePerm(array('administer actions', 'create page content')); - $this->drupalLoginUser($test_user); + $test_user = $this->drupalCreateUser(array('administer actions', 'create page content')); + $this->drupalLogin($test_user); // Set action id to "publish post". $edit = array('aid' => $hash); Index: tests/functional/upload.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/upload.test,v retrieving revision 1.6 diff -u -p -r1.6 upload.test --- tests/functional/upload.test 22 Mar 2008 01:19:17 -0000 1.6 +++ tests/functional/upload.test 22 Mar 2008 02:43:37 -0000 @@ -23,10 +23,10 @@ class upload_module_test_case extends Dr * Create node; upload files to node; and edit, and delete uploads. */ function test_node_upload() { - $admin_user = $this->drupalCreateUserRolePerm(array('administer site configuration')); - $web_user = $this->drupalCreateUserRolePerm(array('access content', 'edit any page content', 'upload files', 'view uploaded files')); + $admin_user = $this->drupalCreateUser(array('administer site configuration')); + $web_user = $this->drupalCreateUser(array('access content', 'edit any page content', 'upload files', 'view uploaded files')); - $this->drupalLoginUser($admin_user); + $this->drupalLogin($admin_user); // Setup upload settings. $edit = array(); @@ -38,7 +38,7 @@ class upload_module_test_case extends Dr $this->assertText('The configuration options have been saved.', 'Upload setting saved.'); $this->drupalGet('logout'); - $this->drupalLoginUser($web_user); + $this->drupalLogin($web_user); // Create a node and attempt to attach files. $node = $this->drupalCreateNode(); @@ -149,8 +149,8 @@ class UploadPictureTests extends DrupalT variable_set('user_pictures', 1); /* Prepare a user to do the stuff */ - $user = $this->drupalCreateUserRolePerm(array('access content')); - $this->drupalLoginUser($user); + $user = $this->drupalCreateUser(array('access content')); + $this->drupalLogin($user); // not a image $img_path = realpath(drupal_get_path('module', 'simpletest'). "/tests/functional/upload.test"); @@ -184,8 +184,8 @@ class UploadPictureTests extends DrupalT variable_set('user_pictures', 1); /* Prepare a user to do the stuff */ - $user = $this->drupalCreateUserRolePerm(array('access content')); - $this->drupalLoginUser($user); + $user = $this->drupalCreateUser(array('access content')); + $this->drupalLogin($user); // changing actual setting; $old_dim = variable_get('user_picture_dimensions', '85x85'); @@ -240,8 +240,8 @@ class UploadPictureTests extends DrupalT variable_set('user_pictures', 1); /* Prepare a user to do the stuff */ - $user = $this->drupalCreateUserRolePerm(array('access content')); - $this->drupalLoginUser($user); + $user = $this->drupalCreateUser(array('access content')); + $this->drupalLogin($user); // changing actual setting; $old_dim = variable_get('user_picture_dimensions', '85x85'); @@ -294,8 +294,8 @@ class UploadPictureTests extends DrupalT variable_set('user_pictures', 1); /* Prepare a user to do the stuff */ - $user = $this->drupalCreateUserRolePerm(array('access content')); - $this->drupalLoginUser($user); + $user = $this->drupalCreateUser(array('access content')); + $this->drupalLogin($user); // changing actual setting; $old_dim = variable_get('user_picture_dimensions', '85x85'); @@ -343,8 +343,8 @@ class UploadPictureTests extends DrupalT variable_set('user_pictures', 1); /* Prepare a user to do the stuff */ - $user = $this->drupalCreateUserRolePerm(array('access content')); - $this->drupalLoginUser($user); + $user = $this->drupalCreateUser(array('access content')); + $this->drupalLogin($user); // changing actual setting; $old_dim = variable_get('user_picture_dimensions', '85x85'); @@ -389,8 +389,8 @@ class UploadPictureTests extends DrupalT variable_set('user_pictures', 1); /* Prepare a user to do the stuff */ - $user = $this->drupalCreateUserRolePerm(array('access content')); - $this->drupalLoginUser($user); + $user = $this->drupalCreateUser(array('access content')); + $this->drupalLogin($user); // changing actual setting; $old_dim = variable_get('user_picture_dimensions', '85x85'); Index: tests/functional/user.test =================================================================== RCS file: /cvs/drupal/contributions/modules/simpletest/tests/functional/user.test,v retrieving revision 1.5 diff -u -p -r1.5 user.test --- tests/functional/user.test 22 Mar 2008 01:19:17 -0000 1.5 +++ tests/functional/user.test 22 Mar 2008 02:43:38 -0000 @@ -249,8 +249,8 @@ class UserDeleteTest extends DrupalTestC $this->drupalPost('user/register', $edit, t('Create new account')); $user_to_delete = user_load($edit); $uid = $user_to_delete->uid; - $web_user = $this->drupalCreateUserRolePerm(array('administer users')); - $this->drupalLoginUser($web_user); + $web_user = $this->drupalCreateUser(array('administer users')); + $this->drupalLogin($web_user); $this->drupalGet(url('user/'. $uid .'/edit', array('absolute' => TRUE))); $this->drupalPost(NULL, array(), t('Delete')); $this->assertWantedRaw(t('Are you sure you want to delete the account %name?', array('%name' => $name)), 'Confirm title');