? modules/field/tests/.field.test.swp
Index: modules/file/file.field.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/file/file.field.inc,v
retrieving revision 1.35
diff -u -p -r1.35 file.field.inc
--- modules/file/file.field.inc	1 Oct 2010 01:32:59 -0000	1.35
+++ modules/file/file.field.inc	7 Oct 2010 01:20:49 -0000
@@ -203,9 +203,9 @@ function file_field_prepare_view($entity
       if (!file_field_displayed($item, $field)) {
         unset($items[$id][$delta]);
       }
-      // Ensure consecutive deltas.
-      $items[$id] = array_values($items[$id]);
     }
+    // Ensure consecutive deltas.
+    $items[$id] = array_values($items[$id]);
   }
 }
 
Index: modules/file/tests/file.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/file/tests/file.test,v
retrieving revision 1.26
diff -u -p -r1.26 file.test
--- modules/file/tests/file.test	1 Oct 2010 01:32:59 -0000	1.26
+++ modules/file/tests/file.test	7 Oct 2010 01:20:49 -0000
@@ -508,37 +508,40 @@ class FileFieldDisplayTestCase extends F
    */
   function testNodeDisplay() {
     $field_name = strtolower($this->randomName());
-    $type_name = 'article';
+    $nid_or_type = 'article';
     $field_settings = array(
       'display_field' => '1',
       'display_default' => '1',
+      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
     );
     $instance_settings = array(
       'description_field' => '1',
     );
     $widget_settings = array();
-    $this->createFileField($field_name, $type_name, $field_settings, $instance_settings, $widget_settings);
+    $this->createFileField($field_name, $nid_or_type, $field_settings, $instance_settings, $widget_settings);
     $field = field_info_field($field_name);
-    $instance = field_info_instance('node', $field_name, $type_name);
-
-    $test_file = $this->getTestFile('text');
-
-    // Create a new node with the uploaded file.
-    $nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
-    $this->drupalGet('node/' . $nid . '/edit');
-
-    // Check that the default formatter is displaying with the file name.
-    $node = node_load($nid, NULL, TRUE);
-    $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
-    $default_output = theme('file_link', array('file' => $node_file));
-    $this->assertRaw($default_output, t('Default formatter displaying correctly on full node view.'));
-
-    // Turn the "display" option off and check that the file is no longer displayed.
-    $edit = array($field_name . '[' . LANGUAGE_NONE . '][0][display]' => FALSE);
-    $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save'));
+    $instance = field_info_instance('node', $field_name, $nid_or_type);
 
-    $this->assertNoRaw($default_output, t('Field is hidden when "display" option is unchecked.'));
+    // Create a couple test files and test formatters for each.
+    for ($i = 0; $i < 3; $i++) {
+      $test_file = $this->getTestFile('text');
+
+      // Create a new node with the uploaded file.
+      $nid_or_type = $this->uploadNodeFile($test_file, $field_name, $nid_or_type);
+      $this->drupalGet('node/' . $nid_or_type . '/edit');
+
+      // Check that the default formatter is displaying with the file name.
+      $node = node_load($nid_or_type, NULL, TRUE);
+      $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][$i];
+      $default_output = theme('file_link', array('file' => $node_file));
+      $this->assertRaw($default_output, t('Default formatter displaying correctly on full node view for field !field.', array('!field' => $i)));
+
+      // Turn the "display" option off and check that the file is no longer displayed.
+      $edit = array($field_name . '[' . LANGUAGE_NONE . '][' . $i . '][display]' => FALSE);
+      $this->drupalPost('node/' . $nid_or_type . '/edit', $edit, t('Save'));
 
+      $this->assertNoRaw($default_output, t('Field !field is hidden when "display" option is unchecked.', array('!field' => $i)));
+    }
   }
 }
 
