Index: tests/upload_tests.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/tests/upload_tests.test,v
retrieving revision 1.9
diff -u -p -r1.9 upload_tests.test
--- tests/upload_tests.test	24 Jun 2007 08:05:07 -0000	1.9
+++ tests/upload_tests.test	24 Jun 2007 08:15:14 -0000
@@ -1,95 +1,12 @@
 <?php
 /* $Id: upload_tests.test,v 1.9 2007/06/24 08:05:07 rokZlender Exp $ */
 class UploadPictureTests extends DrupalTestCase {
-  var $_cleanup_roles = array();
-  var $_cleanup_users = array();
-  var $_directory_test = FALSE;
-
- function _createRolePerm($permissions) {
-    $permstring = implode(', ', $permissions);
-    /* Create 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-'));
-    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);
-      $this->_cleanup_roles[] = $role->rid;
-      return $role->rid;
-    } else {
-      return false;
-    }
-  }
-
-  /**
-   * Creates a user / role / permissions combination specified by permissions
-   *
-   * @return array/boolean false if fails. fully loaded user object with added pass_raw property
-   */
-  function _createUserRolePerm($permissions) {
-    /* Create role */
-    $rid = $this->_createRolePerm($permissions);
-    if (!$rid) {
-      return FALSE;
-    }
-    /* Create user */
-    $ua = array();
-    $ua['name']   = $this->randomName();
-    $ua['mail']   = $ua['name'] . '@example.com';
-    $ua['roles']  = array($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->_cleanup_users[] = $u->uid;
-
-    /* Add the raw password */
-    $u->pass_raw = $ua['pass'];
-    return $u;
-  }
-
-  /**
-   * Logs in a user with the internal browser
-   *
-   * @param object user object with pass_raw property!
-   */
-  function _loginUser($user) {
-    $this->drupalGet( url("user", NULL, NULL, TRUE) );
-    // Going to the page retrieves the cookie, as the browser should save it
-    
-    $edit = array('name' => $user->name, 'pass' => $user->pass_raw);
-    $this->drupalPostRequest('user', $edit, 'Log in');
-    
-    $this->assertText($user->name, ' [login] found name: ' . $user->name);
-    $this->assertNoText(t('The username %name has been blocked.', array('%name' => $user->name)), ' [login] not blocked');
-    $this->assertNoText(t('The name %name is a reserved username.', array('%name' => $user->name)), ' [login] not reserved');
-
-  }
+  
 
   /**
    * Implementation of tearDown, cleaning up created users/roles in db
    */
   function tearDown() {
-    while (sizeof($this->_cleanup_roles) > 0) {
-      $rid = array_pop($this->_cleanup_roles);
-      db_query("DELETE FROM {role} WHERE rid = %d",       $rid);
-      db_query("DELETE FROM {permission} WHERE rid = %d", $rid);
-    }
-    while (sizeof($this->_cleanup_users) > 0) {
-      $uid = array_pop($this->_cleanup_users);
-      db_query('DELETE FROM {users} WHERE uid = %d',       $uid);
-      db_query('DELETE FROM {users_roles} WHERE uid = %d', $uid);
-      db_query('DELETE FROM {authmap} WHERE uid = %d',     $uid);
-    }
     parent::tearDown();
   }
 
@@ -120,8 +37,8 @@ class UploadPictureTests extends DrupalT
     variable_set('user_pictures', 1);
 
     /* Prepare a user to do the stuff */
-    $user = $this->_createUserRolePerm(array('access content'));
-    $this->_loginUser($user);
+    $user = $this->drupalCreateUserRolePerm(array('access content'));
+    $this->drupalLoginUser($user);
 
     // not a image
     $img_path = realpath(drupal_get_path('module', 'simpletest'). "/tests/upload_tests.test");
@@ -155,8 +72,8 @@ class UploadPictureTests extends DrupalT
         variable_set('user_pictures', 1);
 
         /* Prepare a user to do the stuff */
-        $user = $this->_createUserRolePerm(array('access content'));
-        $this->_loginUser($user);
+        $user = $this->drupalCreateUserRolePerm(array('access content'));
+        $this->drupalLoginUser($user);
 
         // changing actual setting;
         $old_dim = variable_get('user_picture_dimensions', '85x85');
@@ -212,8 +129,8 @@ class UploadPictureTests extends DrupalT
         variable_set('user_pictures', 1);
 
         /* Prepare a user to do the stuff */
-        $user = $this->_createUserRolePerm(array('access content'));
-        $this->_loginUser($user);
+        $user = $this->drupalCreateUserRolePerm(array('access content'));
+        $this->drupalLoginUser($user);
 
         // changing actual setting;
         $old_dim = variable_get('user_picture_dimensions', '85x85');
@@ -268,8 +185,8 @@ class UploadPictureTests extends DrupalT
         variable_set('user_pictures', 1);
 
         /* Prepare a user to do the stuff */
-        $user = $this->_createUserRolePerm(array('access content'));
-        $this->_loginUser($user);
+        $user = $this->drupalCreateUserRolePerm(array('access content'));
+        $this->drupalLoginUser($user);
 
         // changing actual setting;
         $old_dim = variable_get('user_picture_dimensions', '85x85');
@@ -317,8 +234,8 @@ class UploadPictureTests extends DrupalT
         variable_set('user_pictures', 1);
 
         /* Prepare a user to do the stuff */
-        $user = $this->_createUserRolePerm(array('access content'));
-        $this->_loginUser($user);
+        $user = $this->drupalCreateUserRolePerm(array('access content'));
+        $this->drupalLoginUser($user);
 
         // changing actual setting;
         $old_dim = variable_get('user_picture_dimensions', '85x85');
@@ -365,8 +282,8 @@ class UploadPictureTests extends DrupalT
       variable_set('user_pictures', 1);
 
       /* Prepare a user to do the stuff */
-      $user = $this->_createUserRolePerm(array('access content'));
-      $this->_loginUser($user);
+      $user = $this->drupalCreateUserRolePerm(array('access content'));
+      $this->drupalLoginUser($user);
 
       // changing actual setting;
       $old_dim = variable_get('user_picture_dimensions', '85x85');
