Index: modules_contrib/cck/tests/content.crud.test
===================================================================
--- modules_contrib/cck/tests/content.crud.test	(revision 177a5601ebd55a1cfb22292f9cb8e8e43ee9fc51)
+++ modules_contrib/cck/tests/content.crud.test	(revision dafc8d817f9621a556e6d99a793880ae9e35a805)
@@ -1,4 +1,3 @@
 <?php
-// $Id: content.crud.test,v 1.4.2.16 2008/12/08 12:41:08 yched Exp $
 
 // TODO:
@@ -22,5 +21,5 @@
   function setUp() {
     $args = func_get_args();
-    $modules = array_merge(array('content', 'schema', 'text'), $args);
+    $modules = array_merge(array('content_test', 'content', 'schema', 'text'), $args);
     call_user_func_array(array('parent','setUp'), $modules);
     module_load_include('inc', 'content', 'includes/content.crud');
@@ -377,5 +376,5 @@
 
 class ContentCrudBasicTest extends ContentCrudTestCase {
-  function getInfo() {
+  public static function getInfo() {
     return array(
       'name' => t('CRUD - Basic API tests'),
@@ -433,5 +432,5 @@
 
 class ContentCrudSingleToMultipleTest extends ContentCrudTestCase {
-  function getInfo() {
+  public static function getInfo() {
     return array(
       'name' => t('CRUD - Single to multiple'),
@@ -508,5 +507,5 @@
 
 class ContentCrudMultipleToSingleTest extends ContentCrudTestCase {
-  function getInfo() {
+  public static function getInfo() {
     return array(
       'name' => t('CRUD - Multiple to single'),
@@ -642,5 +641,5 @@
 
 class ContentUICrud extends ContentCrudTestCase {
-  function getInfo() {
+  public static function getInfo() {
     return array(
       'name' => t('Admin UI'),
@@ -887,5 +886,5 @@
 
 class ContentOptionWidgetTest extends ContentCrudTestCase {
-  function getInfo() {
+  public static function getInfo() {
     return array(
       'name' => t('Option widgets'),
@@ -1235,2 +1234,69 @@
 }
 
+class ContentEmptyDeltaTest extends ContentCrudTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => t('Empty deltas'),
+      'description' => t('Test leaving empty values on a multivalue field and then removing them.'),
+      'group' => t('CCK'),
+    );
+  }
+
+  function setUp() {
+    parent::setUp();
+    $this->loginWithPermissions();
+    $this->acquireContentTypes(1);
+  }
+
+  function testEmptyTextField() {
+    // Create a content type with a multivalue text field.
+    $type = $this->content_types[0];
+    $type_url = str_replace('_', '-', $type->type);
+    $value1 = $this->randomName(5);
+    $value2 = $this->randomName(5);
+    $value3 = $this->randomName(5);
+    $field = $this->createFieldText(array('text_processing' => 0, 'multiple' => 1));
+    $field_name = $field['field_name'];
+
+    // Create a node with three values set.
+    $edit = array(
+      'title' => $this->randomName(20),
+      'body' => $this->randomName(20),
+      'type' => $type->name,
+    );
+    $edit[$field_name][0]['value'] = $value1;
+    $edit[$field_name][1]['value'] = $value2;
+    $edit[$field_name][2]['value'] = $value3;
+    $node = $this->drupalCreateNode($edit);
+    $max_delta = max(array_keys($node->{$field_name}));
+    $this->assertEqual($max_delta, 2, 'Three values saved, highest delta is 2');
+    $this->drupalGet('node/'. $node->nid);
+    $this->assertText($value1, 'First value displayed');
+    $this->assertText($value2, 'Second value displayed');
+    $this->assertText($value3, 'Third value displayed');
+
+    // Set second value to an empty string.
+    $node->{$field_name}[1]['value'] = '';
+    node_save($node);
+    $node = node_load($node->nid, NULL, TRUE);
+    $this->assertIdentical($node->{$field_name}[1]['value'], NULL, 'Second value is empty');
+    $max_delta = max(array_keys($node->{$field_name}));
+    $this->assertEqual($max_delta, 2, 'Three values saved, highest delta is 2');
+    $this->drupalGet('node/'. $node->nid);
+    $this->assertText($value1, 'First value displayed');
+    $this->assertNoText($value2, 'Second value not displayed');
+    $this->assertText($value3, 'Third value displayed');
+
+    // Remove the second value.
+    $node->{$field_name}[1]['_remove'] = 1;
+    node_save($node);
+    $node = node_load($node->nid, NULL, TRUE);
+    $this->assertEqual($node->{$field_name}[1]['value'], $value3, 'Third value has moved to delta 1');
+    $max_delta = max(array_keys($node->{$field_name}));
+    $this->assertEqual($max_delta, 1, 'Two values saved, highest delta is 1');
+    $this->drupalGet('node/'. $node->nid);
+    $this->assertText($value1, 'First value displayed');
+    $this->assertNoText($value2, 'Second value not displayed');
+    $this->assertText($value3, 'Third value displayed');
+  }
+}
