? .bzr
? node_format.patch
? simpletest
? simplify.patch
? upload.patch
? tests/enable_modules.test
? tests/homepage.test
? tests/menu_enable.patch
? tests/menu_tests.patch
Index: drupal_test_case.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/drupal_test_case.php,v
retrieving revision 1.75
diff -u -p -r1.75 drupal_test_case.php
--- drupal_test_case.php	30 Mar 2008 06:25:15 -0000	1.75
+++ drupal_test_case.php	30 Mar 2008 17:47:18 -0000
@@ -8,14 +8,8 @@ class DrupalTestCase extends UnitTestCas
   protected $_logged_in = FALSE;
   protected $_content;
   protected $plain_text;
-  protected $_originalModules     = array();
-  protected $_modules             = array();
-  protected $_cleanupVariables    = array();
-  protected $_cleanupUsers        = array();
-  protected $_cleanupRoles        = array();
-  protected $_cleanupNodes        = array();
-  protected $_cleanupContentTypes = array();
   protected $ch;
+  protected $_modules = array();
   // We do not reuse the cookies in further runs, so we do not need a file
   // but we still need cookie handling, so we set the jar to NULL
   protected $cookie_file = NULL;
@@ -74,7 +68,6 @@ class DrupalTestCase extends UnitTestCas
 
     // small hack to link revisions to our test user
     db_query('UPDATE {node_revisions} SET uid = %d WHERE vid = %d', $node->uid, $node->vid);
-    $this->_cleanupNodes[] = $node->nid;
     return $node;
   }
 
@@ -118,7 +111,6 @@ class DrupalTestCase extends UnitTestCas
     node_type_save($type);
     node_types_rebuild();
 
-    $this->_cleanupContentTypes[] = $type->type;
     return $type;
   }
 
@@ -240,10 +232,6 @@ class DrupalTestCase extends UnitTestCas
     $old_value = variable_get($name, NULL);
     if ($value !== $old_value) {
       variable_set($name, $value);
-      /* Use array_key_exists instead of isset so NULL values do not get overwritten */
-      if (!array_key_exists($name, $this->_cleanupVariables)) {
-        $this->_cleanupVariables[$name] = $old_value;
-      }
     }
   }
 
@@ -278,9 +266,6 @@ class DrupalTestCase extends UnitTestCas
       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;
@@ -311,9 +296,9 @@ class DrupalTestCase extends UnitTestCas
       // 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 {
+    }
+    else {
       return FALSE;
     }
   }
@@ -401,69 +386,7 @@ class DrupalTestCase extends UnitTestCas
       $this->_logged_in = FALSE;
       $this->_modules = $this->_originalModules;
       $this->curlClose();
-      return;
-    }
-    if ($this->_modules != $this->_originalModules) {
-      $form_state['values'] = array('status' => $this->_originalModules, 'op' => t('Save configuration'));
-      drupal_execute('system_modules', $form_state);
-
-      //rebuilding all caches
-      drupal_rebuild_theme_registry();
-      node_types_rebuild();
-      menu_rebuild();
-      cache_clear_all('schema', 'cache');
-      module_rebuild_cache();
-
-      $this->_modules = $this->_originalModules;
-    }
-
-    foreach ($this->_cleanupVariables as $name => $value) {
-      if (is_null($value)) {
-        variable_del($name);
-      } else {
-        variable_set($name, $value);
-      }
-    }
-    $this->_cleanupVariables = array();
-
-    //delete nodes
-    foreach ($this->_cleanupNodes as $nid) {
-      node_delete($nid);
-    }
-    $this->_cleanupNodes = array();
-
-    //delete roles
-    while (sizeof($this->_cleanupRoles) > 0) {
-      $rid = array_pop($this->_cleanupRoles);
-      db_query("DELETE FROM {role} WHERE rid = %d",       $rid);
-      db_query("DELETE FROM {permission} WHERE rid = %d", $rid);
-    }
-
-    //delete users and their content
-    while (sizeof($this->_cleanupUsers) > 0) {
-      $uid = array_pop($this->_cleanupUsers);
-      // cleanup nodes this user created
-      $result = db_query("SELECT nid FROM {node} WHERE uid = %d", $uid);
-      while ($node = db_fetch_array($result)) {
-        node_delete($node['nid']);
-      }
-      user_delete(array(), $uid);
-    }
-
-    //delete content types
-    foreach ($this->_cleanupContentTypes as $type) {
-      node_type_delete($type);
     }
-    $this->_cleanupContentTypes = array();
-
-    //Output drupal warnings and messages into assert messages
-    $drupal_msgs = drupal_get_messages();
-    foreach($drupal_msgs as $type => $msgs) {
-      foreach ($msgs as $msg) {
-        $this->assertTrue(TRUE, "$type: $msg");
-      }
-    }
-
     parent::tearDown();
   }
 
@@ -595,24 +518,33 @@ class DrupalTestCase extends UnitTestCas
           // We try to set the fields of this form as specified in $edit.
           $edit = $edit_save;
           $post = array();
-          $submit_matches = $this->handleForm($post, $edit, $submit, $form);
+          $upload = array();
+          $submit_matches = $this->handleForm($post, $edit, $upload, $submit, $form);
           $action = isset($form['action']) ? $this->getAbsoluteUrl($form['action']) : $this->getUrl();
         }
         // We post only if we managed to handle every field in edit and the
         // submit button matches;
         if (!$edit && $submit_matches) {
-          $encoded_post = '';
-          foreach ($post as $key => $value) {
-            if (is_array($value)) {
-              foreach ($value as $v) {
-                $encoded_post .= $key .'='. rawurlencode($v) .'&';
+          if ($upload) {
+            foreach ($post as &$value) {
+              if ($value[0] == '@') {
+                $this->fail(t("Can't upload and post a value starting with @"));
+                return FALSE;
               }
             }
-            else {
-              $encoded_post .= $key .'='. rawurlencode($value) .'&';
+            foreach ($upload as $key => $file) {
+              $post["@$key"] = $file;
+            }
+          }
+          else {
+            $post_array = $post;
+            $post = array();
+            foreach ($post_array as $key => $value) {
+              $post[] = urlencode($key) .'='. urlencode($value);
             }
+            $post = implode('&', $post);
           }
-          return $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POSTFIELDS => $encoded_post));
+          return $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POSTFIELDS => $post));
         }
       }
       // We have not found a form which contained all fields of $edit.
@@ -624,7 +556,7 @@ class DrupalTestCase extends UnitTestCas
     }
   }
 
-  protected function handleForm(&$post, &$edit, $submit, $form) {
+  protected function handleForm(&$post, &$edit, &$upload, $submit, $form) {
     // Retrieve the form elements.
     $elements = $form->xpath('.//input|.//textarea|.//select');
     $submit_matches = FALSE;
@@ -635,6 +567,7 @@ class DrupalTestCase extends UnitTestCas
       // for <select> or <textarea>.
       $type = isset($element['type']) ? (string)$element['type'] : $element->getName();
       $value = isset($element['value']) ? (string)$element['value'] : '';
+      $done = FALSE;
       if (isset($edit[$name])) {
         switch ($type) {
           case 'text':
@@ -664,41 +597,54 @@ class DrupalTestCase extends UnitTestCas
             break;
           case 'select':
             $new_value = $edit[$name];
+            $index = 0;
+            $key = preg_replace('/\[\]$/', '', $name);
             foreach ($element->option as $option) {
               if (is_array($new_value)) {
                 $option_value= (string)$option['value'];
                 if (in_array($option_value, $new_value)) {
-                  $post[$name][] = $option_value;
+                  $post[$key .'['. $index++ .']'] = $option_value;
+                  $done = TRUE;
                   unset($edit[$name]);
                 }
               }
               elseif ($new_value == $option['value']) {
                 $post[$name] = $new_value;
                 unset($edit[$name]);
+                $done = TRUE;
               }
             }
+            break;
+          case 'file':
+            $upload[$name] = $edit[$name];
+            unset($edit[$name]);
+            break;
         }
       }
       if (($type == 'submit' || $type == 'image') && $submit == $value) {
         $post[$name] = $value;
         $submit_matches = TRUE;
       }
-      if (!isset($post[$name])) {
+      if (!isset($post[$name]) && !$done) {
         switch ($type) {
           case 'textarea':
             $post[$name] = (string)$element;
             break;
           case 'select':
             $single = empty($element['multiple']);
-            foreach ($element->option as $key => $option) {
+            $first = TRUE;
+            $index = 0;
+            $key = preg_replace('/\[\]$/', '', $name);
+            foreach ($element->option as $option) {
               // For single select, we load the first option, if there is a
               // selected option that will overwrite it later.
-              if ($option['selected'] || (!$key && $single)) {
+              if ($option['selected'] || (!$first && $single)) {
+                $first = FALSE;
                 if ($single) {
                   $post[$name] = (string)$option['value'];
                 }
                 else {
-                  $post[$name][] = (string)$option['value'];
+                  $post[$key .'['. $index++ .']'] = (string)$option['value'];
                 }
               }
             }
Index: tests/functional/taxonomy.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/tests/functional/taxonomy.test,v
retrieving revision 1.8
diff -u -p -r1.8 taxonomy.test
--- tests/functional/taxonomy.test	24 Mar 2008 02:36:46 -0000	1.8
+++ tests/functional/taxonomy.test	30 Mar 2008 17:47:18 -0000
@@ -254,7 +254,7 @@ class TaxonomyTestNodeApiTestCase extend
     $edit['hierarchy'] = 1;
     $edit['multiple'] = 1;
     $edit['name'] = $name;
-    $edit['nodes'] = array('story' => 'story');
+    $edit['nodes'] = array('article' => 'article');
     taxonomy_save_vocabulary($edit);
     $vid = $edit['vid']; // we need to persist vid after $edit is unset()
 
@@ -278,20 +278,18 @@ class TaxonomyTestNodeApiTestCase extend
     $patternArray['term name 2'] = $termname;
 
     // create test user and login
-    $perm = array('access content', 'create story content', 'edit own story content', 'delete own story content');
+    $perm = array('access content', 'create article content', 'edit own article content', 'delete own article content');
     $account = $this->drupalCreateUser($perm);
     $this->drupalLogin($account);
 
     // why is this printing out the user profile page?
-    // go to node/add/story
-    // try to create story
+    // go to node/add/article
+    // try to create article
     $title = $this->randomName();
     $body = $this->randomName(100);
     $edit = array('title' => $title, 'body' => $body, "taxonomy[$vid][]" => $parent);
 
-    // multiple slect box was failing through drupalPost. Use raw POST instead
-    // Failing because they were being sent/handled wrong (earnest.berry@gmail.com <Souvent22>)
-    $this->drupalPost('node/add/story', $edit, t('Save'));
+    $this->drupalPost('node/add/article', $edit, t('Save'));
 
     $patternArray['body text'] = $body;
     $patternArray['title'] = $title;
