From cc38147e8737692bb5ba431858795c1641721232 Mon Sep 17 00:00:00 2001
From: Bradley M. Froehle <brad.froehle@gmail.com>
Date: Tue, 22 Feb 2011 01:23:47 -0800
Subject: [PATCH] 1003308 - 33 start forum upgrade test framework

---
 modules/simpletest/simpletest.info                 |    1 +
 .../tests/upgrade/drupal-6.forum.database.php      |  300 ++++++++++++++++++++
 .../simpletest/tests/upgrade/upgrade.forum.test    |   51 ++++
 3 files changed, 352 insertions(+), 0 deletions(-)
 create mode 100644 modules/simpletest/tests/upgrade/drupal-6.forum.database.php
 create mode 100644 modules/simpletest/tests/upgrade/upgrade.forum.test

diff --git modules/simpletest/simpletest.info modules/simpletest/simpletest.info
index 732c707..7222758 100644
--- modules/simpletest/simpletest.info
+++ modules/simpletest/simpletest.info
@@ -40,6 +40,7 @@ files[] = tests/xmlrpc.test
 files[] = tests/upgrade/upgrade.test
 files[] = tests/upgrade/upgrade.comment.test
 files[] = tests/upgrade/upgrade.filter.test
+files[] = tests/upgrade/upgrade.forum.test
 files[] = tests/upgrade/upgrade.node.test
 files[] = tests/upgrade/upgrade.taxonomy.test
 files[] = tests/upgrade/upgrade.upload.test
diff --git modules/simpletest/tests/upgrade/drupal-6.forum.database.php modules/simpletest/tests/upgrade/drupal-6.forum.database.php
new file mode 100644
index 0000000..3545c4a
--- /dev/null
+++ modules/simpletest/tests/upgrade/drupal-6.forum.database.php
@@ -0,0 +1,300 @@
+<?php
+// $Id$
+
+/**
+ * Database additions for locale tests.
+ */
+
+db_create_table('forum', array(
+  'fields' => array(
+    'nid' => array(
+      'type' => 'int',
+      'unsigned' => TRUE,
+      'not null' => TRUE,
+      'default' => 0,
+    ),
+    'vid' => array(
+      'type' => 'int',
+      'unsigned' => TRUE,
+      'not null' => TRUE,
+      'default' => 0,
+    ),
+    'tid' => array(
+      'type' => 'int',
+      'unsigned' => TRUE,
+      'not null' => TRUE,
+      'default' => 0,
+    ),
+  ),
+  'indexes' => array(
+    'nid' => array(
+      'nid',
+    ),
+    'tid' => array(
+      'tid',
+    ),
+  ),
+  'primary key' => array(
+    'vid',
+  ),
+  'module' => 'forum',
+  'name' => 'forum',
+));
+db_insert('forum')->fields(array(
+  'nid',
+  'vid',
+  'tid',
+))
+->values(array(
+  'nid' => '101',
+  'vid' => '101',
+  'tid' => '103',
+))
+->values(array(
+  'nid' => '102',
+  'vid' => '102',
+  'tid' => '102',
+))
+->execute();
+
+
+
+db_insert('node')->fields(array(
+  'nid',
+  'vid',
+  'type',
+  'language',
+  'title',
+  'uid',
+  'status',
+  'created',
+  'changed',
+  'comment',
+  'promote',
+  'moderate',
+  'sticky',
+  'tnid',
+  'translate',
+))
+->values(array(
+  'nid' => '101',
+  'vid' => '101',
+  'type' => 'forum',
+  'language' => '',
+  'title' => 'Berkeley Bowl',
+  'uid' => '1',
+  'status' => '1',
+  'created' => '1298363952',
+  'changed' => '1298363952',
+  'comment' => '2',
+  'promote' => '0',
+  'moderate' => '0',
+  'sticky' => '0',
+  'tnid' => '0',
+  'translate' => '0',
+))
+->values(array(
+  'nid' => '102',
+  'vid' => '102',
+  'type' => 'forum',
+  'language' => '',
+  'title' => 'Chez Panisse',
+  'uid' => '1',
+  'status' => '1',
+  'created' => '1298364001',
+  'changed' => '1298364001',
+  'comment' => '2',
+  'promote' => '0',
+  'moderate' => '0',
+  'sticky' => '0',
+  'tnid' => '0',
+  'translate' => '0',
+))
+->execute();
+
+db_insert('node_revisions')->fields(array(
+  'nid',
+  'vid',
+  'uid',
+  'title',
+  'body',
+  'teaser',
+  'log',
+  'timestamp',
+  'format',
+))
+->values(array(
+  'nid' => '101',
+  'vid' => '101',
+  'uid' => '1',
+  'title' => 'Berkeley Bowl',
+  'body' => 'Lots of produce.',
+  'teaser' => 'Lots of produce.',
+  'log' => '',
+  'timestamp' => '1298363952',
+  'format' => '1',
+))
+->values(array(
+  'nid' => '102',
+  'vid' => '102',
+  'uid' => '1',
+  'title' => 'Chez Panisse',
+  'body' => 'The original.',
+  'teaser' => 'The original.',
+  'log' => '',
+  'timestamp' => '1298364001',
+  'format' => '1',
+))
+->execute();
+
+db_insert('node_type')->fields(array(
+  'type',
+  'name',
+  'module',
+  'description',
+  'help',
+  'has_title',
+  'title_label',
+  'has_body',
+  'body_label',
+  'min_word_count',
+  'custom',
+  'modified',
+  'locked',
+  'orig_type',
+))
+->values(array(
+  'type' => 'forum',
+  'name' => 'Forum topic',
+  'module' => 'forum',
+  'description' => 'A <em>forum topic</em> is the initial post to a new discussion thread within a forum.',
+  'help' => '',
+  'has_title' => '1',
+  'title_label' => 'Subject',
+  'has_body' => '1',
+  'body_label' => 'Body',
+  'min_word_count' => '0',
+  'custom' => '0',
+  'modified' => '0',
+  'locked' => '1',
+  'orig_type' => 'forum',
+))
+->execute();
+
+db_insert('term_data')->fields(array(
+  'tid',
+  'vid',
+  'name',
+  'description',
+  'weight',
+))
+->values(array(
+  'tid' => '101',
+  'vid' => '101',
+  'name' => 'Food',
+  'description' => '',
+  'weight' => '0',
+))
+->values(array(
+  'tid' => '102',
+  'vid' => '101',
+  'name' => 'Restaurants',
+  'description' => 'Discussion of restaurants.',
+  'weight' => '0',
+))
+->values(array(
+  'tid' => '103',
+  'vid' => '101',
+  'name' => 'Grocery Stores',
+  'description' => 'Discussion of Grocery Stores',
+  'weight' => '0',
+))
+->execute();
+
+db_insert('term_hierarchy')->fields(array(
+  'tid',
+  'parent',
+))
+->values(array(
+  'tid' => '101',
+  'parent' => '0',
+))
+->values(array(
+  'tid' => '102',
+  'parent' => '101',
+))
+->values(array(
+  'tid' => '103',
+  'parent' => '101',
+))
+->execute();
+
+db_insert('term_node')->fields(array(
+  'nid',
+  'vid',
+  'tid',
+))
+->values(array(
+  'nid' => '101',
+  'vid' => '101',
+  'tid' => '103',
+))
+->values(array(
+  'nid' => '102',
+  'vid' => '102',
+  'tid' => '102',
+))
+->execute();
+
+db_insert('variable')->fields(array(
+  'name',
+  'value',
+))
+->values(array(
+  'name' => 'forum_nav_vocabulary',
+  'value' => 's:3:"101";',
+))
+->values(array(
+  'name' => 'forum_containers',
+  'value' => 'a:1:{i:0;s:3:"101";}',
+))
+->execute();
+
+db_insert('vocabulary')->fields(array(
+  'vid',
+  'name',
+  'description',
+  'help',
+  'relations',
+  'hierarchy',
+  'multiple',
+  'required',
+  'tags',
+  'module',
+  'weight',
+))
+->values(array(
+  'vid' => '101',
+  'name' => 'Vocabulary 101',
+  'description' => 'Vocabulary used for Forums. The name is changed from the default "Forums" so that the upgrade path may be tested.',
+  'help' => '',
+  'relations' => '1',
+  'hierarchy' => '1',
+  'multiple' => '0',
+  'required' => '0',
+  'tags' => '0',
+  'module' => 'forum',
+  'weight' => '-10',
+))
+->execute();
+
+db_insert('vocabulary_node_types')->fields(array(
+  'vid',
+  'type',
+))
+->values(array(
+  'vid' => '101',
+  'type' => 'forum',
+))
+->execute();
+
diff --git modules/simpletest/tests/upgrade/upgrade.forum.test modules/simpletest/tests/upgrade/upgrade.forum.test
new file mode 100644
index 0000000..a2fe078
--- /dev/null
+++ modules/simpletest/tests/upgrade/upgrade.forum.test
@@ -0,0 +1,51 @@
+<?php
+// $Id$
+
+/**
+ * Upgrade test for forum.module.
+ */
+class ForumUpgradePathTestCase extends UpgradePathTestCase {
+  public static function getInfo() {
+    return array(
+      'name'  => 'Forum upgrade path',
+      'description'  => 'Upgrade path tests for the Forum module.',
+      'group' => 'Upgrade path',
+    );
+  }
+
+  public function setUp() {
+    // Path to the database dump files.
+    $this->databaseDumpFiles = array(
+      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.filled.database.php',
+      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.forum.database.php',
+    );
+    parent::setUp();
+
+    $this->uninstallModulesExcept(array('comment', 'forum', 'taxonomy'));
+  }
+
+  /**
+   * Test a successful upgrade (no negotiation).
+   */
+  public function testForumUpgrade() {
+    $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.'));
+
+    // Re-enable modules
+    $edit = array();
+    $edit['modules[Core][comment][enable]'] = 'comment';
+    $edit['modules[Core][forum][enable]'] = 'forum';
+    $edit['modules[Core][taxonomy][enable]'] = 'taxonomy';
+    $this->drupalPost('admin/modules', $edit, t('Save configuration'));
+
+    $this->drupalGet('node/101');
+    $this->drupalGet('node/102');
+
+    $this->drupalGet('forum/101');
+    $this->drupalGet('forum/102');
+    $this->drupalGet('forum/103');
+
+    $this->drupalGet('taxonomy/term/101');
+    $this->drupalGet('taxonomy/term/102');
+    $this->drupalGet('taxonomy/term/103');
+    }
+}
-- 
1.7.3.5

