summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/node/node.install16
-rw-r--r--modules/simpletest/simpletest.info2
-rw-r--r--modules/simpletest/tests/upgrade/drupal-6.filled.database.php41
-rw-r--r--modules/simpletest/tests/upgrade/upgrade.node.test95
-rw-r--r--scripts/generate-d6-content.sh20
5 files changed, 172 insertions, 2 deletions
diff --git a/modules/node/node.install b/modules/node/node.install
index 81ad93b3e..e51e7f15c 100644
--- a/modules/node/node.install
+++ b/modules/node/node.install
@@ -512,10 +512,24 @@ function node_update_7006(&$sandbox) {
$result = db_select('node_type', 'node_type')
->fields('node_type')
->execute();
+ foreach ($result as $type_object) {
+ $node_types[$type_object->type] = $type_object;
+ }
+ $extra_types = db_query('SELECT DISTINCT type FROM {node} WHERE type NOT IN (:types)', array(':types' => array_keys($node_types)))->fetchCol();
+ foreach ($extra_types as $type) {
+ $type_object = new stdClass;
+ $type_object->type = $type;
+ // Always create a body. Querying node_revisions for a non-empty body
+ // would skip creating body fields for types that have a body but
+ // the nodes of that type so far had empty bodies.
+ $type_object->has_body = 1;
+ $type_object->body_label = 'Body';
+ $node_types[$type_object->type] = $type_object;
+ }
$default_trim_length = variable_get('teaser_length', 600);
// Add body field instances for existing node types.
- foreach ($result as $node_type) {
+ foreach ($node_types as $node_type) {
if ($node_type->has_body) {
$instance = node_add_body_field($node_type, $node_type->body_label);
// Update newly created instance to convert teaser_length variable
diff --git a/modules/simpletest/simpletest.info b/modules/simpletest/simpletest.info
index 0143e92f9..94c1b8006 100644
--- a/modules/simpletest/simpletest.info
+++ b/modules/simpletest/simpletest.info
@@ -39,5 +39,5 @@ files[] = tests/unicode.test
files[] = tests/update.test
files[] = tests/xmlrpc.test
files[] = tests/upgrade/upgrade.test
-files[] = tests/upgrade/upgrade.poll.test
+files[] = tests/upgrade/upgrade.node.test
files[] = tests/upgrade/upgrade.taxonomy.test
diff --git a/modules/simpletest/tests/upgrade/drupal-6.filled.database.php b/modules/simpletest/tests/upgrade/drupal-6.filled.database.php
index 16112b010..2bd4a54e9 100644
--- a/modules/simpletest/tests/upgrade/drupal-6.filled.database.php
+++ b/modules/simpletest/tests/upgrade/drupal-6.filled.database.php
@@ -9788,6 +9788,23 @@ db_insert('node')->fields(array(
'tnid' => '0',
'translate' => '0',
))
+->values(array(
+ 'nid' => '37',
+ 'vid' => '49',
+ 'type' => 'broken',
+ 'language' => '',
+ 'title' => 'node title 24',
+ 'uid' => '6',
+ 'status' => '1',
+ 'created' => '1263769200',
+ 'changed' => '1279310614',
+ 'comment' => '0',
+ 'promote' => '0',
+ 'moderate' => '0',
+ 'sticky' => '0',
+ 'tnid' => '0',
+ 'translate' => '0',
+))
->execute();
db_create_table('node_access', array(
@@ -10158,6 +10175,13 @@ db_insert('node_comment_statistics')->fields(array(
'last_comment_uid' => '5',
'comment_count' => '0',
))
+->values(array(
+ 'nid' => '37',
+ 'last_comment_timestamp' => '1279310615',
+ 'last_comment_name' => NULL,
+ 'last_comment_uid' => '6',
+ 'comment_count' => '0',
+))
->execute();
db_create_table('node_counter', array(
@@ -10798,6 +10822,17 @@ db_insert('node_revisions')->fields(array(
'timestamp' => '1282936268',
'format' => '0',
))
+->values(array(
+ 'nid' => '37',
+ 'vid' => '49',
+ 'uid' => '6',
+ 'title' => 'node title 24',
+ 'body' => 'node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37',
+ 'teaser' => 'node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37node body (broken) - 37no',
+ 'log' => 'added 12 node',
+ 'timestamp' => '1279310614',
+ 'format' => '0',
+))
->execute();
db_create_table('node_type', array(
@@ -19284,6 +19319,12 @@ db_insert('url_alias')->fields(array(
'dst' => 'content/poll/11/results',
'language' => '',
))
+->values(array(
+ 'pid' => '49',
+ 'src' => 'node/37',
+ 'dst' => 'content/1263769200',
+ 'language' => '',
+))
->execute();
db_create_table('users', array(
diff --git a/modules/simpletest/tests/upgrade/upgrade.node.test b/modules/simpletest/tests/upgrade/upgrade.node.test
new file mode 100644
index 000000000..0299ffa2a
--- /dev/null
+++ b/modules/simpletest/tests/upgrade/upgrade.node.test
@@ -0,0 +1,95 @@
+<?php
+// $Id$
+
+/**
+ * Upgrade test for node bodies.
+ *
+ * Load a filled installation of Drupal 6 and run the upgrade process on it.
+ */
+class NodeBodyUpgradePathTestCase extends UpgradePathTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Node body upgrade path',
+ 'description' => 'Node body upgrade path tests.',
+ 'group' => 'Upgrade path',
+ );
+ }
+
+ public function setUp() {
+ // Path to the database dump.
+ $this->databaseDumpFile = drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.filled.database.php';
+ parent::setUp();
+ }
+
+ /**
+ * Test a successful upgrade.
+ */
+ public function testNodyBodyUpgrade() {
+ $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.'));
+ $this->drupalGet("content/1263769200");
+ $this->assertText('node body (broken) - 37');
+ }
+}
+
+/**
+ * Upgrade test for node type poll.
+ *
+ * Load a bare installation of Drupal 6 and run the upgrade process on it.
+ *
+ * The install only contains dblog (although it's optional, it's only so that
+ * another hook_watchdog module can take its place, the site is not functional
+ * without watchdog) and update.
+ */
+class PollUpgradePathTestCase extends UpgradePathTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Poll upgrade path',
+ 'description' => 'Poll upgrade path tests.',
+ 'group' => 'Upgrade path',
+ );
+ }
+
+ public function setUp() {
+ // Path to the database dump.
+ $this->databaseDumpFile = drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.filled.database.php';
+ parent::setUp();
+
+ $this->uninstallModulesExcept(array('poll'));
+ }
+
+ /**
+ * Test a successful upgrade.
+ */
+ public function testPollUpgrade() {
+ $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.'));
+
+ // Check modules page for poll
+ $this->drupalGet('admin/modules');
+
+ // Verify that the poll data is still correctly available
+ for ($i = 0; $i < 12; $i++) {
+ $this->drupalGet("content/poll/$i");
+
+ $nbchoices = ($i % 4) + 2;
+
+ for ($c = 0; $c < $nbchoices; $c++) {
+ $this->assertText("Choice $c for poll $i", t('Choice text is displayed correctly on poll view'));
+ }
+
+ // Now check that the votes are correct
+ $this->clickLink(t('Results'));
+
+ for ($c = 0; $c < $nbchoices; $c++) {
+ $this->assertText("Choice $c for poll $i", t('Choice text is displayed correctly on result view'));
+ }
+
+ $nbvotes = floor (($i % 4) + 5);
+ $elements = $this->xpath("//div[@class='percent']");
+ for ($c = 0; $c < $nbchoices; $c++) {
+ $votes = floor($nbvotes / $nbchoices);
+ if (($nbvotes % $nbchoices) > $c) $votes++;
+ $this->assertTrue(preg_match("/$votes vote/", $elements[$c]), t('The number of votes is displayed correctly: expected ' . $votes . ', got ' . $elements[$c]));
+ }
+ }
+ }
+}
diff --git a/scripts/generate-d6-content.sh b/scripts/generate-d6-content.sh
index d51b22188..c4dc952d9 100644
--- a/scripts/generate-d6-content.sh
+++ b/scripts/generate-d6-content.sh
@@ -185,3 +185,23 @@ for ($i = 0; $i < 12; $i++) {
drupal_execute('poll_view_voting', $form_state, $node);
}
}
+
+$uid = 6;
+$user = user_load($uid);
+$node = new stdClass;
+$node->uid = $uid;
+$node->type = 'broken';
+$node->sticky = 0;
+$node->title = "node title 24";
+$node->body = str_repeat("node body ($node->type) - 37", 100);
+$node->teaser = node_teaser($node->body);
+$node->filter = variable_get('filter_default_format', 1);
+$node->format = FILTER_FORMAT_DEFAULT;
+$node->status = 1;
+$node->language = '';
+$node->revision = 0;
+$node->promote = 0;
+$node->created = 1263769200;
+$node->log = "added $i node";
+node_save($node);
+path_set_alias("node/$node->nid", "content/1263769200");