5 * Generate content for a Drupal 6 database to test the upgrade process.
7 * Run this script at the root of an existing Drupal 6 installation.
8 * Steps to use this generation script:
10 * - Run this script from your Drupal ROOT directory.
11 * - Use the dump-database-d6.sh to generate the D7 file
12 * modules/simpletest/tests/upgrade/database.filled.php
17 $_SERVER['HTTP_HOST'] = 'default';
18 $_SERVER['PHP_SELF'] = '/index.php';
19 $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
20 $_SERVER['SERVER_SOFTWARE'] = NULL;
21 $_SERVER['REQUEST_METHOD'] = 'GET';
22 $_SERVER['QUERY_STRING'] = '';
23 $_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = '/';
24 $_SERVER['HTTP_USER_AGENT'] = 'console';
25 $modules_to_enable = array('path', 'poll');
28 include_once './includes/bootstrap.inc';
29 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
31 // Enable requested modules
32 include_once './modules/system/system.admin.inc';
33 $form = system_modules();
34 foreach ($modules_to_enable as $module) {
35 $form_state['values']['status'][$module] = TRUE;
37 $form_state['values']['disabled_modules'] = $form['disabled_modules'];
38 system_modules_submit(NULL, $form_state);
41 // Run cron after installing
45 for ($i = 0; $i < 6; $i++) {
46 $name = "test user $i";
47 $pass = md5("test PassW0rd $i !(.)");
48 $mail = "test$i@example.com";
49 $now = mktime(0, 0, 0, 1, $i + 1, 2010);
50 db_query("INSERT INTO {users} (name, pass, mail, status, created, access) VALUES ('%s', '%s', '%s', %d, %d, %d)", $name, $pass, $mail, 1, $now, $now);
54 // Create vocabularies and terms
58 // All possible combinations of these vocabulary properties.
59 $hierarchy = array(0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2);
60 $multiple = array(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1);
61 $required = array(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1);
65 for ($i = 0; $i < 24; $i++) {
66 $vocabulary = array();
68 $vocabulary['name'] = "vocabulary $voc_id (i=$i)";
69 $vocabulary['description'] = "description of ". $vocabulary['name'];
70 $vocabulary['nodes'] = $i > 11 ? array('page' => TRUE) : array();
71 $vocabulary['multiple'] = $multiple[$i % 12];
72 $vocabulary['required'] = $required[$i % 12];
73 $vocabulary['relations'] = 1;
74 $vocabulary['hierarchy'] = $hierarchy[$i % 12];
75 $vocabulary['weight'] = $i;
76 taxonomy_save_vocabulary($vocabulary);
78 // Vocabularies without hierarchy get one term, single parent vocabularies get
79 // one parent and one child term. Multiple parent vocabularies get three
80 // terms: t0, t1, t2 where t0 is a parent of both t1 and t2.
81 for ($j = 0; $j < $vocabulary['hierarchy'] + 1; $j++) {
83 $term['vid'] = $vocabulary['vid'];
84 // For multiple parent vocabularies, omit the t0-t1 relation, otherwise
85 // every parent in the vocabulary is a parent.
86 $term['parent'] = $vocabulary['hierarchy'] == 2 && i == 1 ? array() : $parents;
88 $term['name'] = "term $term_id of vocabulary $voc_id (j=$j)";
89 $term['description'] = 'description of ' . $term['name'];
90 $term['weight'] = $i * 3 + $j;
91 taxonomy_save_term($term);
92 $terms[] = $term['tid'];
93 $parents[] = $term['tid'];
99 module_load_include('inc', 'node', 'node.pages');
100 for ($i = 0; $i < 24; $i++) {
101 $uid = intval($i / 8) + 3;
102 $user = user_load($uid);
103 $node = new stdClass();
105 $node->type = $i < 12 ? 'page' : 'story';
109 $node->title = "node title $node_id rev $revision_id (i=$i)";
110 $type = node_get_types('type', $node->type);
111 if ($type->has_body) {
112 $node->body = str_repeat("node body ($node->type) - $i", 100);
113 $node->teaser = node_teaser($node->body);
114 $node->filter = variable_get('filter_default_format', 1);
115 $node->format = FILTER_FORMAT_DEFAULT;
117 $node->status = intval($i / 4) % 2;
118 $node->language = '';
119 $node->revision = $i < 12;
120 $node->promote = $i % 2;
121 $node->created = $now + $i * 86400;
122 $node->log = "added $i node";
123 // Make every term association different a little. For nodes with revisions,
124 // make the initial revision have a different set of terms than the
126 $node_terms = $terms;
127 unset($node_terms[$i], $node_terms[47 - $i]);
128 if ($node->revision) {
129 $node->taxonomy = array($i => $terms[$i], 47-$i => $terms[47 - $i]);
132 $node->taxonomy = $node_terms;
135 path_set_alias("node/$node->nid", "content/$node->created");
136 if ($node->revision) {
137 $user = user_load($uid + 3);
139 $node->title .= " rev2 $revision_id";
140 $node->body = str_repeat("node revision body ($node->type) - $i", 100);
141 $node->log = "added $i revision";
142 $node->taxonomy = $node_terms;
147 // Create poll content
148 for ($i = 0; $i < 12; $i++) {
149 $uid = intval($i / 4) + 3;
150 $user = user_load($uid);
151 $node = new stdClass();
153 $node->type = 'poll';
155 $node->title = "poll title $i";
156 $type = node_get_types('type', $node->type);
157 if ($type->has_body) {
158 $node->body = str_repeat("node body ($node->type) - $i", 100);
159 $node->teaser = node_teaser($node->body);
160 $node->filter = variable_get('filter_default_format', 1);
161 $node->format = FILTER_FORMAT_DEFAULT;
163 $node->status = intval($i / 2) % 2;
164 $node->language = '';
166 $node->promote = $i % 2;
167 $node->created = $now + $i * 43200;
168 $node->log = "added $i poll";
170 $nbchoices = ($i % 4) + 2;
171 for ($c = 0; $c < $nbchoices; $c++) {
172 $node->choice[] = array('chtext' => "Choice $c for poll $i");
175 path_set_alias("node/$node->nid", "content/poll/$i");
176 path_set_alias("node/$node->nid/results", "content/poll/$i/results");
179 for ($v = 0; $v < ($i % 4) + 5; $v++) {
180 $c = $v % $nbchoices;
181 $form_state = array();
182 $form_state['values']['choice'] = $c;
183 $form_state['values']['op'] = t('Vote');
184 drupal_execute('poll_view_voting', $form_state, $node);
189 $user = user_load($uid);
190 $node = new stdClass();
192 $node->type = 'broken';
194 $node->title = "node title 24";
195 $node->body = str_repeat("node body ($node->type) - 37", 100);
196 $node->teaser = node_teaser($node->body);
197 $node->filter = variable_get('filter_default_format', 1);
198 $node->format = FILTER_FORMAT_DEFAULT;
200 $node->language = '';
203 $node->created = 1263769200;
204 $node->log = "added $i node";
206 path_set_alias("node/$node->nid", "content/1263769200");