Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.86
diff -u -9 -p -r1.86 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	22 Feb 2009 20:12:03 -0000	1.86
+++ modules/simpletest/drupal_web_test_case.php	8 Mar 2009 21:40:39 -0000
@@ -602,27 +602,26 @@ class DrupalWebTestCase {
     }
     usort($files, array($this, 'drupalCompareFiles'));
     return $files;
   }
 
   /**
    * Compare two files based on size and file name.
    */
   protected function drupalCompareFiles($file1, $file2) {
-    // Determine which file is larger.
-    $compare_size = (filesize($file1->filepath) > filesize($file2->filepath));
-    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);
+    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);
     }
   }
 
   /**
    * Generates a random string.
    *
    * @param $number
    *   Number of characters in length to append to the prefix.
    * @param $prefix
Index: modules/user/user.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.test,v
retrieving revision 1.29
diff -u -9 -p -r1.29 user.test
--- modules/user/user.test	22 Feb 2009 17:55:30 -0000	1.29
+++ modules/user/user.test	8 Mar 2009 21:40:40 -0000
@@ -562,19 +562,21 @@ class UserPictureTestCase extends Drupal
    *
    * results: The image should be uploaded because ImageGDToolkit resizes the picture
    */
   function testWithGDinvalidSize() {
     if ($this->_directory_test)
       if (image_get_toolkit()) {
 
         $this->drupalLogin($this->user);
 
-        $image = current($this->drupalGetTestFiles('image'));
+        // Images are sorted first by size then by name. We need an image
+        // bigger than 1 KB so we'll grab the last one.
+        $image = end($this->drupalGetTestFiles('image'));
         $info = image_get_info($image->filepath);
 
         // Set new variables: valid dimensions, invalid filesize.
         $test_dim = ($info['width'] + 10) . 'x' . ($info['height'] + 10);
         $test_size = 1;
         variable_set('user_picture_dimensions', $test_dim);
         variable_set('user_picture_file_size', $test_size);
 
         $pic_path = $this->saveUserPicture($image);
