diff --git a/modules/simpletest/tests/upgrade/drupal-6.upload.database.php b/modules/simpletest/tests/upgrade/drupal-6.upload.database.php index 50025b4..ff3f382 100644 --- a/modules/simpletest/tests/upgrade/drupal-6.upload.database.php +++ b/modules/simpletest/tests/upgrade/drupal-6.upload.database.php @@ -127,8 +127,8 @@ db_insert('files')->fields(array( 'status' => '1', 'timestamp' => '1285708958', )) -// Under some configurations we end up having two fids with the same filepath, -//see https://www.drupal.org/node/1260938. +// On some Drupal 6 sites, more than one file can have the same filepath. See +// https://www.drupal.org/node/1260938. ->values(array( 'fid' => '12', 'uid' => '1', @@ -149,6 +149,16 @@ db_insert('files')->fields(array( 'status' => '1', 'timestamp' => '1285708958', )) +->values(array( + 'fid' => '14', + 'uid' => '1', + 'filename' => 'duplicate-name.png', + 'filepath' => 'sites/default/files/duplicate-name.png', + 'filemime' => 'image/png', + 'filesize' => '314', + 'status' => '1', + 'timestamp' => '1285708958', +)) ->execute(); db_insert('node')->fields(array( @@ -309,8 +319,8 @@ db_insert('node_revisions')->fields(array( 'vid' => '55', 'uid' => '1', 'title' => 'node title 41 revision 55', - 'body' => "Attachments:\r\nduplicate-name.png", - 'teaser' => "Attachments:\r\nduplicate-name.png", + 'body' => "Attachments:\r\nduplicate-name.png\r\nduplicate-name.png", + 'teaser' => "Attachments:\r\nduplicate-name.png\r\nduplicate-name.png", 'log' => '', 'timestamp' => '1285709012', 'format' => '1', @@ -488,7 +498,15 @@ db_insert('upload')->fields(array( 'fid' => '13', 'nid' => '41', 'vid' => '55', - 'description' => 'duplicate-name.png', + 'description' => 'first description', + 'list' => '0', + 'weight' => '0', +)) +->values(array( + 'fid' => '14', + 'nid' => '41', + 'vid' => '55', + 'description' => 'second description', 'list' => '1', 'weight' => '0', )) diff --git a/modules/simpletest/tests/upgrade/upgrade.upload.test b/modules/simpletest/tests/upgrade/upgrade.upload.test index b43c367..9b6ed89 100644 --- a/modules/simpletest/tests/upgrade/upgrade.upload.test +++ b/modules/simpletest/tests/upgrade/upgrade.upload.test @@ -74,13 +74,20 @@ class UploadUpgradePathTestCase extends UpgradePathTestCase { // Ensure that duplicate filepaths are reduced. $node0 = node_load(41, 54); $node1 = node_load(41, 55); - // Ensure that both revisions point to the same FID. + // Ensure that both revisions point to the same file ID. $items0 = field_get_items('node', $node0, 'upload'); $this->assertEqual(count($items0), 1); $items1 = field_get_items('node', $node1, 'upload'); - $this->assertEqual(count($items1), 1); + $this->assertEqual(count($items1), 2); $this->assertEqual($items0[0]['fid'], $items1[0]['fid']); - + $this->assertEqual($items0[0]['fid'], $items1[1]['fid']); + // The revision with more than one reference to the same file should retain + // the original settings for each reference. + $this->assertEqual($items1[0]['description'], 'first description'); + $this->assertEqual($items1[0]['display'], 0); + $this->assertEqual($items1[1]['description'], 'second description'); + $this->assertEqual($items1[1]['display'], 1); + // No duplicate files should remain on the Drupal 7 site. $this->assertEqual(0, db_query("SELECT COUNT(*) FROM {file_managed} GROUP BY uri HAVING COUNT(fid) > 1")->fetchField()); // Make sure the file settings were properly migrated.