Index: drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.2.2.3.2.36
diff -u -r1.2.2.3.2.36 drupal_web_test_case.php
--- drupal_web_test_case.php	23 Apr 2009 05:04:57 -0000	1.2.2.3.2.36
+++ drupal_web_test_case.php	23 Apr 2009 05:37:51 -0000
@@ -1,5 +1,6 @@
 <?php
 // $Id: drupal_web_test_case.php,v 1.2.2.3.2.36 2009/04/23 05:04:57 boombatower Exp $
+// Core: Id: drupal_web_test_case.php,v 1.96 2009/04/22 09:57:10 dries Exp
 /**
  * @file
  * Provide required modifications to Drupal 7 core DrupalWebTestCase in order
@@ -65,11 +66,11 @@
   protected $elements = NULL;
 
   /**
-   * Whether a user is logged in the internal browser.
+   * The current user logged in using the internal browser.
    *
    * @var bool
    */
-  protected $isLoggedIn = FALSE;
+  protected $loggedInUser = FALSE;
 
   /**
    * The current cookie file used by cURL.
@@ -158,7 +159,7 @@
    *   the name of the source file, 'line' is the line number and 'function'
    *   is the caller function itself.
    */
-  protected function assert($status, $message = '', $group = 'Other', array $caller = NULL) {
+  private function assert($status, $message = '', $group = 'Other', array $caller = NULL) {
     global $db_prefix;
 
     // Convert boolean status to string status.
@@ -499,7 +500,7 @@
    */
   protected function drupalCreateNode($settings = array()) {
     // Populate defaults array
-    $defaults = array(
+    $settings += array(
       'body'      => $this->randomName(32),
       'title'     => $this->randomName(8),
       'comment'   => 2,
@@ -516,18 +517,30 @@
       'revisions' => NULL,
       'taxonomy'  => NULL,
     );
-    $defaults['teaser'] = $defaults['body'];
-    // If we already have a node, we use the original node's created time, and this
-    if (isset($defaults['created'])) {
-      $defaults['date'] = format_date($defaults['created'], 'custom', 'Y-m-d H:i:s O');
-    }
-    if (empty($settings['uid'])) {
-      global $user;
-      $defaults['uid'] = $user->uid;
+
+    // Use the original node's created time for existing nodes.
+    if (isset($settings['created']) && !isset($settings['date'])) {
+      $settings['date'] = format_date($settings['created'], 'custom', 'Y-m-d H:i:s O');
+    }
+
+    // Add the default teaser.
+    if (!isset($settings['teaser'])) {
+      $settings['teaser'] = $settings['body'];      
+    }
+
+    // If the node's user uid is not specified manually, use the currently
+    // logged in user if available, or else the user running the test.
+    if (!isset($settings['uid'])) {
+      if ($this->loggedInUser) {
+        $settings['uid'] = $this->loggedInUser->uid;
+      }
+      else {
+        global $user;
+        $settings['uid'] = $user->uid;
+      }
     }
-    $node = ($settings + $defaults);
-    $node = (object)$node;
 
+    $node = (object) $settings;
     node_save($node);
 
     // small hack to link revisions to our test user
@@ -610,8 +623,10 @@
       // If size is set then remove any files that are not of that size.
       if ($size !== NULL) {
         foreach ($files as $file) {
+//          $stats = stat($file->filepath);
           $stats = stat($file->filename);
           if ($stats['size'] != $size) {
+//            unset($files[$file->filepath]);
             unset($files[$file->filename]);
           }
         }
@@ -625,15 +640,15 @@
    * Compare two files based on size and file name.
    */
   protected function drupalCompareFiles($file1, $file2) {
-    // Determine which file is larger.
-    $compare_size = (filesize($file1->filename) > filesize($file2->filename));
-    if (!$compare_size) {
-      // Both files were the same size, so return whichever one is alphabetically greater.
-      return strnatcmp($file1->name, $file2->name);
+//    $compare_size = filesize($file1->filepath) - filesize($file2->filepath);
+    $compare_size = filesize($file1->filename) - filesize($file2->filename);
+    if ($compare_size) {
+      // Sort by file size.
+      return $compare_size;
     }
     else {
-      // Return TRUE if $file1 is larger than $file2.
-      return $compare_size;
+      // The files were the same size, so sort alphabetically.
+      return strnatcmp($file1->name, $file2->name);
     }
   }
 
@@ -793,7 +808,7 @@
    * @see drupalCreateUser()
    */
   protected function drupalLogin(stdClass $user) {
-    if ($this->isLoggedIn) {
+    if ($this->loggedInUser) {
       $this->drupalLogout();
     }
 
@@ -807,7 +822,9 @@
     $pass = $pass && $this->assertNoText(t('The username %name has been blocked.', array('%name' => $user->name)), t('No blocked message at login page'), t('User login'));
     $pass = $pass && $this->assertNoText(t('The name %name is a reserved username.', array('%name' => $user->name)), t('No reserved message at login page'), t('User login'));
 
-    $this->isLoggedIn = $pass;
+    if ($pass) {
+      $this->loggedInUser = $user;
+    }
   }
 
   /*
@@ -823,7 +840,9 @@
     $pass = $this->assertField('name', t('Username field found.'), t('Logout'));
     $pass = $pass && $this->assertField('pass', t('Password field found.'), t('Logout'));
 
-    $this->isLoggedIn = !$pass;
+    if ($pass) {
+      $this->loggedInUser = FALSE;
+    }
   }
 
   /**
@@ -886,6 +905,7 @@
     // Log in with a clean $user.
     $this->originalUser = $user;
 //    drupal_save_session(FALSE);
+//    $user = user_load(1);
     session_save_session(FALSE);
     $user = user_load(array('uid' => 1));
 
@@ -899,7 +919,9 @@
     $this->originalFileDirectory = file_directory_path();
     variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
     $directory = file_directory_path();
-    file_check_directory($directory, FILE_CREATE_DIRECTORY); // Create the files directory.
+    // Create the files directory.
+    file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+
     set_time_limit($this->timeLimit);
   }
 
@@ -939,6 +961,7 @@
     global $db_prefix, $user;
     if (preg_match('/simpletest\d+/', $db_prefix)) {
       // Delete temporary files directory and reset files directory path.
+//      file_unmanaged_delete_recursive(file_directory_path());
       simpletest_clean_temporary_directory(file_directory_path());
       variable_set('file_directory_path', $this->originalFileDirectory);
 
@@ -964,7 +987,7 @@
       }
 
       // Ensure that internal logged in variable and cURL options are reset.
-      $this->isLoggedIn = FALSE;
+      $this->loggedInUser = FALSE;
       $this->additionalCurlOptions = array();
 
       // Reload module list and implementations to ensure that test module hooks
@@ -999,6 +1022,7 @@
         CURLOPT_COOKIEJAR => $this->cookieFile,
         CURLOPT_URL => $base_url,
         CURLOPT_FOLLOWLOCATION => TRUE,
+        CURLOPT_MAXREDIRS => 5,
         CURLOPT_RETURNTRANSFER => TRUE,
         CURLOPT_SSL_VERIFYPEER => FALSE,  // Required to make the tests run on https://
         CURLOPT_SSL_VERIFYHOST => FALSE,  // Required to make the tests run on https://
@@ -1028,10 +1052,25 @@
   protected function curlExec($curl_options) {
     $this->curlInitialize();
     $url = empty($curl_options[CURLOPT_URL]) ? curl_getinfo($this->curlHandle, CURLINFO_EFFECTIVE_URL) : $curl_options[CURLOPT_URL];
+    if (!empty($curl_options[CURLOPT_POST])) {
+      // This is a fix for the Curl library to prevent Expect: 100-continue
+      // headers in POST requests, that may cause unexpected HTTP response
+      // codes from some webservers (like lighttpd that returns a 417 error
+      // code). It is done by setting an empty "Expect" header field that is
+      // not overwritten by Curl.
+      $curl_options[CURLOPT_HTTPHEADER][] = 'Expect:';
+    }
     curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
     $this->headers = array();
     $this->drupalSetContent(curl_exec($this->curlHandle), curl_getinfo($this->curlHandle, CURLINFO_EFFECTIVE_URL));
-    $this->assertTrue($this->content !== FALSE, t('!method to !url, response is !length bytes.', array('!method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'), '!url' => $url, '!length' => strlen($this->content))), t('Browser'));
+    $message_vars = array(
+      '!method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'),
+      '@url' => $url,
+      '@status' => curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE),
+      '!length' => format_size(strlen($this->content))
+    );
+    $message = t('!method @url returned @status (!length).', $message_vars);
+    $this->assertTrue($this->content !== FALSE, $message, t('Browser'));
     return $this->drupalGetContent();
   }
 
@@ -1743,6 +1782,78 @@
   }
 
   /**
+   * Pass if the text is found ONLY ONCE on the text version of the page.
+   *
+   * The text version is the equivalent of what a user would see when viewing
+   * through a web browser. In other words the HTML has been filtered out of
+   * the contents.
+   *
+   * @param $text
+   *   Plain text to look for.
+   * @param $message
+   *   Message to display.
+   * @param $group
+   *   The group this message belongs to, defaults to 'Other'.
+   * @return
+   *   TRUE on pass, FALSE on fail.
+   */
+  protected function assertUniqueText($text, $message = '', $group = 'Other') {
+    return $this->assertUniqueTextHelper($text, $message, $group, TRUE);
+  }
+
+  /**
+   * Pass if the text is found MORE THAN ONCE on the text version of the page.
+   *
+   * The text version is the equivalent of what a user would see when viewing
+   * through a web browser. In other words the HTML has been filtered out of
+   * the contents.
+   *
+   * @param $text
+   *   Plain text to look for.
+   * @param $message
+   *   Message to display.
+   * @param $group
+   *   The group this message belongs to, defaults to 'Other'.
+   * @return
+   *   TRUE on pass, FALSE on fail.
+   */
+  protected function assertNoUniqueText($text, $message = '', $group = 'Other') {
+    return $this->assertUniqueTextHelper($text, $message, $group, FALSE);
+  }
+
+  /**
+   * Helper for assertUniqueText and assertNoUniqueText.
+   *
+   * It is not recommended to call this function directly.
+   *
+   * @param $text
+   *   Plain text to look for.
+   * @param $message
+   *   Message to display.
+   * @param $group
+   *   The group this message belongs to.
+   * @param $be_unique
+   *   TRUE if this text should be found only once, FALSE if it should be found more than once.
+   * @return
+   *   TRUE on pass, FALSE on fail.
+   */
+  protected function assertUniqueTextHelper($text, $message, $group, $be_unique) {
+    if ($this->plainTextContent === FALSE) {
+      $this->plainTextContent = filter_xss($this->content, array());
+    }
+    if (!$message) {
+      $message = '"' . $text . '"'. ($be_unique ? ' found only once' : ' found more than once');
+    }
+    $first_occurance = strpos($this->plainTextContent, $text);
+    if ($first_occurance === FALSE) {
+      return $this->assert(FALSE, $message, $group);
+    }
+    $offset = $first_occurance + strlen($text);
+    $second_occurance = strpos($this->plainTextContent, $text, $offset);
+    return $this->assert($be_unique == ($second_occurance === FALSE), $message, $group);
+  }
+
+  /**
    * Will trigger a pass if the Perl regex pattern is found in the raw content.
    *
    * @param $pattern
@@ -1787,7 +1898,7 @@
    *   TRUE on pass, FALSE on fail.
    */
   protected function assertTitle($title, $message, $group = 'Other') {
-    return $this->assertTrue($this->xpath('//title[text()="' . $title . '"]'), $message, $group);
+    return $this->assertEqual(current($this->xpath('//title')), $title, $message, $group);
   }
 
   /**
@@ -1803,7 +1914,7 @@
    *   TRUE on pass, FALSE on fail.
    */
   protected function assertNoTitle($title, $message, $group = 'Other') {
-    return $this->assertFalse($this->xpath('//title[text()="' . $title . '"]'), $message, $group);
+    return $this->assertNotEqual(current($this->xpath('//title')), $title, $message, $group);
   }
 
   /**
@@ -2044,57 +2155,4 @@
     $match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
     return $this->assertTrue($match, $message ? $message : t('HTTP response expected !code, actual !curl_code', array('!code' => $code, '!curl_code' => $curl_code)), t('Browser'));
   }
-  
-  /**
-   * TODO write documentation.
-   * @param $type
-   * @param $field_name
-   * @param $settings
-   * @return unknown_type
-   */
-  protected function drupalCreateField($type, $field_name = NULL, $settings = array()) {
-    if (!isset($field_name)) {
-      $field_name = strtolower($this->randomName());
-    }
-    $field_definition = array(
-      'field_name' => $field_name,
-      'type' => $type,
-    );
-    $field_definition += $settings;
-    field_create_field($field_definition);
-    
-    $field = field_read_field($field_name);
-    $this->assertTrue($field, t('Created field @field_name of type @type.', array('@field_name' => $field_name, '@type' => $type)));
-    
-    return $field;
-  }
-  
-  /**
-   * TODO write documentation.
-   * @param $field_name
-   * @param $widget_type
-   * @param $display_type
-   * @param $bundle
-   * @return unknown_type
-   */
-  protected function drupalCreateFieldInstance($field_name, $widget_type, $formatter_type, $bundle) {
-    $instance_definition = array(
-      'field_name' => $field_name,
-      'bundle' => $bundle,
-      'widget' => array(
-        'type' => $widget_type,
-      ),
-      'display' => array(
-        'full' => array(
-          'type' => $formatter_type,
-        ),
-      ),
-    );
-    field_create_instance($instance_definition);
-    
-    $instance = field_read_instance($field_name, $bundle);
-    $this->assertTrue($instance, t('Created instance of field @field_name on bundle @bundle.', array('@field_name' => $field_name, '@bundle' => $bundle)));
-    
-    return $instance;
-  }
 }
Index: simpletest.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/simpletest.module,v
retrieving revision 1.33.2.4.2.16
diff -u -r1.33.2.4.2.16 simpletest.module
--- simpletest.module	28 Mar 2009 03:35:17 -0000	1.33.2.4.2.16
+++ simpletest.module	23 Apr 2009 05:37:51 -0000
@@ -1,5 +1,6 @@
 <?php
 // $Id: simpletest.module,v 1.33.2.4.2.16 2009/03/28 03:35:17 boombatower Exp $
+// Core: Id: simpletest.module,v 1.39 2009/03/31 01:49:53 webchick Exp
 /**
  * @file
  * Backport of Drupal 7 simpletest.module with modifications, see BACKPORT.txt.
@@ -40,6 +41,12 @@
  * Implementation of hook_perm().
  */
 function simpletest_perm() {
+//  return array(
+//    'administer unit tests' => array(
+//      'title' => t('Administer unit tests'),
+//      'description' => t('Manage and run automated testing. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))),
+//    ),
+//  );
   return array('administer unit tests');
 }
 
@@ -90,7 +97,7 @@
     $header = array(t('Message'), t('Group'), t('Filename'), t('Line'), t('Function'), array('colspan' => 2, 'data' => t('Status')));
     while ($result = db_fetch_object($results)) {
       $class = $result->test_class;
-      $info = $uncategorized_tests[$class]->getInfo();
+      $info = call_user_func(array($class, 'getInfo'));
       $group = $info['group'];
       $selected_tests[$group][$class] = TRUE;
       if (!isset($group_summary[$group])) {
@@ -124,17 +131,14 @@
     }
 
     // Clear test results.
-    if (variable_get('simpletest_clear_results', TRUE)) {
-      db_query('DELETE FROM {simpletest} WHERE test_id = %d', $_SESSION['test_id']);
-      db_query('DELETE FROM {simpletest_test_id} WHERE test_id = %d', $_SESSION['test_id']);
-    }
+    simpletest_clean_results_table($_SESSION['test_id']);
     unset($_SESSION['test_id']);
 
     $all_ok = TRUE;
     foreach ($form['results'] as $group => &$elements) {
       $group_ok = TRUE;
       foreach ($elements as $class => &$element) {
-        $info = $uncategorized_tests[$class]->getInfo();
+        $info = call_user_func(array($class, 'getInfo'));
         $ok = $element['summary']['#fail'] + $element['summary']['#exception'] == 0;
         $element += array(
           '#type' => 'fieldset',
@@ -171,15 +175,13 @@
     $form['tests']['table'][$group_name] = array(
       '#collapsed' => TRUE,
     );
-    foreach ($test_group as $test) {
-      $test_info = $test->getInfo();
-      $test_class = get_class($test);
-      $is_selected = isset($selected_tests[$group_name][$test_class]);
-      $form['tests']['table'][$group_name][$test_class] = array(
+    foreach ($test_group as $class => $info) {
+      $is_selected = isset($selected_tests[$group_name][$class]);
+      $form['tests']['table'][$group_name][$class] = array(
         '#type' => 'checkbox',
-        '#title' => $test_info['name'],
+        '#title' => $info['name'],
         '#default_value' => $is_selected,
-        '#description' => $test_info['description'],
+        '#description' => $info['description'],
       );
       if ($is_selected) {
         $form['tests']['table'][$group_name]['#collapsed'] = FALSE;
@@ -488,21 +490,22 @@
 
     $existing_classes = get_declared_classes();
     foreach ($files as $file) {
+//      include_once DRUPAL_ROOT . '/' . $file;
       include_once $file;
     }
     $classes = array_values(array_diff(get_declared_classes(), $existing_classes));
     $formatted_classes = array();
     foreach ($classes as $key => $class) {
-      if (method_exists($class, 'getInfo')) {
-        $formatted_classes[$class] = new $class;
+      if (!method_exists($class, 'getInfo')) {
+        unset($classes[$key]);
       }
     }
   }
-  if (count($formatted_classes) == 0) {
+  if (count($classes) == 0) {
     drupal_set_message('No test cases found.', 'error');
     return FALSE;
   }
-  return $formatted_classes;
+  return $classes;
 }
 
 /**
@@ -514,9 +517,9 @@
  */
 function simpletest_categorize_tests($tests) {
   $groups = array();
-  foreach ($tests as $test => $instance) {
-    $info = $instance->getInfo();
-    $groups[$info['group']][$test] = $instance;
+  foreach ($tests as $test) {
+    $info = call_user_func(array($test, 'getInfo'));
+    $groups[$info['group']][$test] = $info;
   }
   uksort($groups, 'strnatcasecmp');
   return $groups;
@@ -528,7 +531,8 @@
 function simpletest_clean_environment() {
   simpletest_clean_database();
   simpletest_clean_temporary_directories();
-  simpletest_clean_results_table();
+  $count = simpletest_clean_results_table();
+  drupal_set_message(t('Removed @count test results.', array('@count' => $count)));
 }
 
 /**
@@ -556,7 +560,7 @@
 }
 
 /**
- * Find all tables that are like the specified base table name.
+ * Find all tables that are like the specified base table name. (Drupal 6)
  *
  * @param string $base_table Base table name.
  * @param boolean $count Return the table count instead of list of tables.
@@ -601,7 +605,7 @@
 }
 
 /**
- * Remove all files from specified directory and then remove directory.
+ * Remove all files from specified directory and then remove directory. (Drupal 6)
  *
  * @param string $path Directory path.
  */
@@ -623,22 +627,45 @@
 }
 
 /**
- * Clear the test results tables.
+ * Clear the test result tables.
+ *
+ * @param $test_id
+ *   Test ID to remove results for, or NULL to remove all results.
+ * @return
+ *   The number of results removed or FALSE.
  */
-function simpletest_clean_results_table() {
+function simpletest_clean_results_table($test_id = NULL) {
   if (variable_get('simpletest_clear_results', TRUE)) {
-    $count = db_result(db_query('SELECT COUNT(test_id) FROM {simpletest_test_id}'));
+    if ($test_id) {
+//      $count = db_result(db_query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = :test_id', array(':test_id' => $test_id)));
+      $count = db_result(db_query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = %d', $test_id));
 
-    // Clear test results.
-    db_query('DELETE FROM {simpletest}');
-    db_query('DELETE FROM {simpletest_test_id}');
+//      db_delete("simpletest")
+//        ->condition('test_id', $test_id)
+//        ->execute();
+//      db_delete("simpletest_test_id")
+//        ->condition('test_id', $test_id)
+//        ->execute();
+      db_query("DELETE FROM {simpletest} WHERE test_id = %d", $test_id);
+      db_query("DELETE FROM {simpletest_test_id} WHERE test_id = %d", $test_id);
+    }
+    else {
+      $count = db_result(db_query('SELECT COUNT(test_id) FROM {simpletest_test_id}'));
+
+      // Clear test results.
+//      db_delete("simpletest")->execute();
+//      db_delete("simpletest_test_id")->execute();
+      db_query('DELETE FROM {simpletest}');
+      db_query('DELETE FROM {simpletest_test_id}');
+    }
 
-    drupal_set_message(t('Removed @count test results.', array('@count' => $count)));
+    return $count;
   }
+  return FALSE;
 }
 
 /**
- * Implementation of hook_form_FORM_ID_alter(): system_modules.
+ * Implementation of hook_form_FORM_ID_alter(): system_modules. (Drupal 6)
  *
  * Hide modules that have 'hidden = TRUE' in their .info files.
  */
Index: BACKPORT.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/Attic/BACKPORT.txt,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 BACKPORT.txt
--- BACKPORT.txt	8 Feb 2009 03:59:56 -0000	1.1.2.4
+++ BACKPORT.txt	23 Apr 2009 05:37:50 -0000
@@ -16,13 +16,14 @@
 is then commented out. This makes it easy to see what was done when merging
 later changes.
 
+The last backported core CVS ID for the file is listed just bellow the actual
+CVS ID with the prefix "Core: ".
+
 DrupalWebTestCase
 -----------------
-All changes are made in the root DrupalWebTestCase which extends the core
-DrupalWebTestCase which is renamed to DrupalWebTestCaseCore and placed in the
-core sub-folder.
+Document as described above.
 
-Error/Exception handling (core/functions.inc)
+Error/Exception handling (simpletest.function.inc)
 ---------------------------------------------
 The necessary core error/exception handling function from common.inc.
 
Index: simpletest.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/Attic/simpletest.test,v
retrieving revision 1.1.2.10
diff -u -r1.1.2.10 simpletest.test
--- simpletest.test	13 Mar 2009 03:31:07 -0000	1.1.2.10
+++ simpletest.test	23 Apr 2009 05:37:51 -0000
@@ -1,5 +1,6 @@
 <?php
 // $Id: simpletest.test,v 1.1.2.10 2009/03/13 03:31:07 boombatower Exp $
+// Core: Id: simpletest.test,v 1.17 2009/03/31 01:49:53 webchick Exp
 /**
  * @file
  * Backport of Drupal 7 simpletest.test with modifications, see BACKPORT.txt.
@@ -19,7 +20,7 @@
    */
   protected $test_ids = array();
 
-  function getInfo() {
+  public static function getInfo() {
     return array(
       'name' => t('SimpleTest functionality'),
       'description' => t('Test SimpleTest\'s web interface: check that the intended tests were
Index: run-tests.sh
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/Attic/run-tests.sh,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 run-tests.sh
--- run-tests.sh	13 Apr 2009 20:28:11 -0000	1.1.2.3
+++ run-tests.sh	23 Apr 2009 05:37:51 -0000
@@ -1,5 +1,6 @@
 <?php
 // $Id: run-tests.sh,v 1.1.2.3 2009/04/13 20:28:11 boombatower Exp $
+// Core: Id: run-tests.sh,v 1.26 2009/04/13 12:23:26 dries Exp
 /**
  * @file
  * Backport of Drupal 7 run-tests.sh with modifications, see BACKPORT.txt.
@@ -58,8 +59,7 @@
   echo   "-------------------------------\n\n";
   foreach ($groups as $group => $tests) {
     echo $group . "\n";
-    foreach ($tests as $class_name => $instance) {
-      $info = $instance->getInfo();
+    foreach ($tests as $class_name => $info) {
       echo " - " . $info['name'] . ' (' . $class_name . ')' . "\n";
     }
   }
@@ -87,11 +87,7 @@
 simpletest_script_reporter_display_results();
 
 // Cleanup our test results.
-//db_delete("simpletest")
-//  ->condition('test_id', $test_id)
-//  ->execute();
-db_query("DELETE FROM {simpletest} WHERE test_id = %d", $test_id);
-
+simpletest_clean_results_table($test_id);
 
 /**
  * Print help text.
@@ -387,13 +383,13 @@
 
   $test_list = array();
   if ($args['all']) {
-    $test_list = array_keys($all_tests);
+    $test_list = $all_tests;
   }
   else {
     if ($args['class']) {
       // Check for valid class names.
       foreach ($args['test_names'] as $class_name) {
-        if (isset($all_tests[$class_name])) {
+        if (in_array($class_name, $all_tests)) {
           $test_list[] = $class_name;
         }
       }
@@ -405,7 +401,7 @@
       }
 
       // Check for valid class names.
-      foreach ($all_tests as $class_name => $instance) {
+      foreach ($all_tests as $class_name => $info) {
         $refclass = new ReflectionClass($class_name);
         $file = $refclass->getFileName();
         if (isset($files[$file])) {
@@ -417,7 +413,7 @@
       // Check for valid group names and get all valid classes in group.
       foreach ($args['test_names'] as $group_name) {
         if (isset($groups[$group_name])) {
-          foreach($groups[$group_name] as $class_name => $instance) {
+          foreach($groups[$group_name] as $class_name => $info) {
             $test_list[] = $class_name;
           }
         }
@@ -450,7 +446,7 @@
   else {
     echo "Tests to be run:\n";
     foreach ($test_list as $class_name) {
-      $info = $all_tests[$class_name]->getInfo();
+      $info = call_user_func(array($class_name, 'getInfo'));
       echo " - " . $info['name'] . ' (' . $class_name . ')' . "\n";
     }
     echo "\n";
Index: simpletest.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/simpletest.info,v
retrieving revision 1.4.2.2.2.3
diff -u -r1.4.2.2.2.3 simpletest.info
--- simpletest.info	8 Feb 2009 02:35:39 -0000	1.4.2.2.2.3
+++ simpletest.info	23 Apr 2009 05:37:51 -0000
@@ -2,5 +2,7 @@
 name = "SimpleTest"
 description = "Provides a framework for unit and functional testing."
 package = Development
-core = 6.x
-PHP = 5.x
+version = VERSION
+core = 7.x
+files[] = simpletest.module
+files[] = simpletest.install
Index: simpletest.function.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/Attic/simpletest.function.inc,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 simpletest.function.inc
--- simpletest.function.inc	23 Apr 2009 05:04:57 -0000	1.1.2.1
+++ simpletest.function.inc	23 Apr 2009 05:37:51 -0000
@@ -1,5 +1,6 @@
 <?php
 // $Id: simpletest.function.inc,v 1.1.2.1 2009/04/23 05:04:57 boombatower Exp $
+// Core: Id: common.inc,v 1.878 2009/04/22 09:45:02 dries Exp
 /**
  * @file
  * Provide backported function from Drupal 7 core required by SimpleTest.
@@ -167,7 +168,7 @@
   }
 
   if ($fatal) {
-    drupal_set_header($_SERVER['SERVER_PROTOCOL'] . ' Service unavailable');
+    drupal_set_header('503 Service unavailable');
     drupal_set_title(t('Error'));
     if (!defined('MAINTENANCE_MODE') && drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL) {
       // To conserve CPU and bandwidth, omit the blocks.
Index: simpletest.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/simpletest.install,v
retrieving revision 1.4.2.3.2.15
diff -u -r1.4.2.3.2.15 simpletest.install
--- simpletest.install	8 Feb 2009 02:46:50 -0000	1.4.2.3.2.15
+++ simpletest.install	23 Apr 2009 05:37:51 -0000
@@ -1,5 +1,6 @@
 <?php
 // $Id: simpletest.install,v 1.4.2.3.2.15 2009/02/08 02:46:50 boombatower Exp $
+// Core: Id: simpletest.install,v 1.17 2009/03/29 23:14:53 webchick Exp
 /**
  * @file
  * Backport of Drupal 7 simpletest.install with modifications, see BACKPORT.txt.
@@ -39,6 +40,7 @@
       $original = drupal_get_path('module', 'simpletest') . '/files';
       $files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/');
       foreach ($files as $file) {
+//        file_unmanaged_copy($file->filepath, $path);
         file_unmanaged_copy($file->filename, $path . '/' . $file->basename);
       }
       $generated = TRUE;
@@ -98,6 +100,8 @@
  * Implementation of hook_uninstall().
  */
 function simpletest_uninstall() {
+  simpletest_clean_environment();
+
   variable_del('simpletest_httpauth');
   variable_del('simpletest_httpauth_username');
   variable_del('simpletest_httpauth_pass');
Index: CHANGELOG.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/Attic/CHANGELOG.txt,v
retrieving revision 1.1.2.78
diff -u -r1.1.2.78 CHANGELOG.txt
--- CHANGELOG.txt	23 Apr 2009 05:04:57 -0000	1.1.2.78
+++ CHANGELOG.txt	23 Apr 2009 05:37:50 -0000
@@ -18,6 +18,9 @@
    * #409294 by wlp1979: Add extra condition to getAssertionCall() for DrupalWebTestCaseCore.
    * Merge DrupalWebTestCase change into DrupalWebTestCaseCore.
    * Move "core" directory files into root.
+   * Full backport of Drupal 7 SimpleTest and common.inc functions.
+     - Requires getInfo() methods to be changed to: public static getInfo().
+       Look in simpletest.test and test/block.test for examples.
 
 SimpleTest 6.x-2.7, 2009-02-16
 ------------------------------
Index: tests/block.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/tests/Attic/block.test,v
retrieving revision 1.1.2.1.2.1
diff -u -r1.1.2.1.2.1 block.test
--- tests/block.test	8 Feb 2009 02:46:50 -0000	1.1.2.1.2.1
+++ tests/block.test	23 Apr 2009 05:37:51 -0000
@@ -11,7 +11,7 @@
   /**
    * Implementation of getInfo().
    */
-  function getInfo() {
+  public static function getInfo() {
     return array(
       'name' => t('Block functionality'),
       'description' => t('Add, edit and delete custom block. Configure and move a module-defined block.'),
