summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.26/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.26/scripts')
-rw-r--r--kolab.org/www/drupal-7.26/scripts/code-clean.sh9
-rw-r--r--kolab.org/www/drupal-7.26/scripts/cron-curl.sh3
-rw-r--r--kolab.org/www/drupal-7.26/scripts/cron-lynx.sh3
-rwxr-xr-xkolab.org/www/drupal-7.26/scripts/drupal.sh144
-rw-r--r--kolab.org/www/drupal-7.26/scripts/dump-database-d6.sh101
-rw-r--r--kolab.org/www/drupal-7.26/scripts/dump-database-d7.sh90
-rw-r--r--kolab.org/www/drupal-7.26/scripts/generate-d6-content.sh206
-rw-r--r--kolab.org/www/drupal-7.26/scripts/generate-d7-content.sh320
-rwxr-xr-xkolab.org/www/drupal-7.26/scripts/password-hash.sh90
-rwxr-xr-xkolab.org/www/drupal-7.26/scripts/run-tests.sh676
-rw-r--r--kolab.org/www/drupal-7.26/scripts/test.script4
11 files changed, 1646 insertions, 0 deletions
diff --git a/kolab.org/www/drupal-7.26/scripts/code-clean.sh b/kolab.org/www/drupal-7.26/scripts/code-clean.sh
new file mode 100644
index 0000000..3338b6a
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/scripts/code-clean.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+find . -name "*~" -type f | xargs rm -f
+find . -name ".#*" -type f | xargs rm -f
+find . -name "*.rej" -type f | xargs rm -f
+find . -name "*.orig" -type f | xargs rm -f
+find . -name "DEADJOE" -type f | xargs rm -f
+find . -type f | grep -v ".psp" | grep -v ".gif" | grep -v ".jpg" | grep -v ".png" | grep -v ".tgz" | grep -v ".ico" | grep -v "druplicon" | xargs perl -wi -pe 's/\s+$/\n/'
+find . -type f | grep -v ".psp" | grep -v ".gif" | grep -v ".jpg" | grep -v ".png" | grep -v ".tgz" | grep -v ".ico" | grep -v "druplicon" | xargs perl -wi -pe 's/\t/ /g'
diff --git a/kolab.org/www/drupal-7.26/scripts/cron-curl.sh b/kolab.org/www/drupal-7.26/scripts/cron-curl.sh
new file mode 100644
index 0000000..9b168ab
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/scripts/cron-curl.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+curl --silent --compressed http://example.com/cron.php
diff --git a/kolab.org/www/drupal-7.26/scripts/cron-lynx.sh b/kolab.org/www/drupal-7.26/scripts/cron-lynx.sh
new file mode 100644
index 0000000..904667a
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/scripts/cron-lynx.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+/usr/bin/lynx -source http://example.com/cron.php > /dev/null 2>&1
diff --git a/kolab.org/www/drupal-7.26/scripts/drupal.sh b/kolab.org/www/drupal-7.26/scripts/drupal.sh
new file mode 100755
index 0000000..76bd750
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/scripts/drupal.sh
@@ -0,0 +1,144 @@
+#!/usr/bin/env php
+<?php
+
+/**
+ * Drupal shell execution script
+ *
+ * Check for your PHP interpreter - on Windows you'll probably have to
+ * replace line 1 with
+ * #!c:/program files/php/php.exe
+ *
+ * @param path Drupal's absolute root directory in local file system (optional).
+ * @param URI A URI to execute, including HTTP protocol prefix.
+ */
+$script = basename(array_shift($_SERVER['argv']));
+
+if (in_array('--help', $_SERVER['argv']) || empty($_SERVER['argv'])) {
+ echo <<<EOF
+
+Execute a Drupal page from the shell.
+
+Usage: {$script} [OPTIONS] "<URI>"
+Example: {$script} "http://mysite.org/node"
+
+All arguments are long options.
+
+ --help This page.
+
+ --root Set the working directory for the script to the specified path.
+ To execute Drupal this has to be the root directory of your
+ Drupal installation, f.e. /home/www/foo/drupal (assuming Drupal
+ running on Unix). Current directory is not required.
+ Use surrounding quotation marks on Windows.
+
+ --verbose This option displays the options as they are set, but will
+ produce errors from setting the session.
+
+ URI The URI to execute, i.e. http://default/foo/bar for executing
+ the path '/foo/bar' in your site 'default'. URI has to be
+ enclosed by quotation marks if there are ampersands in it
+ (f.e. index.php?q=node&foo=bar). Prefix 'http://' is required,
+ and the domain must exist in Drupal's sites-directory.
+
+ If the given path and file exists it will be executed directly,
+ i.e. if URI is set to http://default/bar/foo.php
+ and bar/foo.php exists, this script will be executed without
+ bootstrapping Drupal. To execute Drupal's cron.php, specify
+ http://default/cron.php as the URI.
+
+
+To run this script without --root argument invoke it from the root directory
+of your Drupal installation with
+
+ ./scripts/{$script}
+\n
+EOF;
+ exit;
+}
+
+// define default settings
+$cmd = 'index.php';
+$_SERVER['HTTP_HOST'] = 'default';
+$_SERVER['PHP_SELF'] = '/index.php';
+$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
+$_SERVER['SERVER_SOFTWARE'] = NULL;
+$_SERVER['REQUEST_METHOD'] = 'GET';
+$_SERVER['QUERY_STRING'] = '';
+$_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = '/';
+$_SERVER['HTTP_USER_AGENT'] = 'console';
+
+// toggle verbose mode
+if (in_array('--verbose', $_SERVER['argv'])) {
+ $_verbose_mode = true;
+}
+else {
+ $_verbose_mode = false;
+}
+
+// parse invocation arguments
+while ($param = array_shift($_SERVER['argv'])) {
+ switch ($param) {
+ case '--root':
+ // change working directory
+ $path = array_shift($_SERVER['argv']);
+ if (is_dir($path)) {
+ chdir($path);
+ if ($_verbose_mode) {
+ echo "cwd changed to: {$path}\n";
+ }
+ }
+ else {
+ echo "\nERROR: {$path} not found.\n\n";
+ }
+ break;
+
+ default:
+ if (substr($param, 0, 2) == '--') {
+ // ignore unknown options
+ break;
+ }
+ else {
+ // parse the URI
+ $path = parse_url($param);
+
+ // set site name
+ if (isset($path['host'])) {
+ $_SERVER['HTTP_HOST'] = $path['host'];
+ }
+
+ // set query string
+ if (isset($path['query'])) {
+ $_SERVER['QUERY_STRING'] = $path['query'];
+ parse_str($path['query'], $_GET);
+ $_REQUEST = $_GET;
+ }
+
+ // set file to execute or Drupal path (clean URLs enabled)
+ if (isset($path['path']) && file_exists(substr($path['path'], 1))) {
+ $_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = $path['path'];
+ $cmd = substr($path['path'], 1);
+ }
+ elseif (isset($path['path'])) {
+ if (!isset($_GET['q'])) {
+ $_REQUEST['q'] = $_GET['q'] = $path['path'];
+ }
+ }
+
+ // display setup in verbose mode
+ if ($_verbose_mode) {
+ echo "Hostname set to: {$_SERVER['HTTP_HOST']}\n";
+ echo "Script name set to: {$cmd}\n";
+ echo "Path set to: {$_GET['q']}\n";
+ }
+ }
+ break;
+ }
+}
+
+if (file_exists($cmd)) {
+ include $cmd;
+}
+else {
+ echo "\nERROR: {$cmd} not found.\n\n";
+}
+exit();
diff --git a/kolab.org/www/drupal-7.26/scripts/dump-database-d6.sh b/kolab.org/www/drupal-7.26/scripts/dump-database-d6.sh
new file mode 100644
index 0000000..41146b0
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/scripts/dump-database-d6.sh
@@ -0,0 +1,101 @@
+#!/usr/bin/env php
+<?php
+
+/**
+ * Dump a Drupal 6 database into a Drupal 7 PHP script to test the upgrade
+ * process.
+ *
+ * Run this script at the root of an existing Drupal 6 installation.
+ *
+ * The output of this script is a PHP script that can be ran inside Drupal 7
+ * and recreates the Drupal 6 database as dumped. Transient data from cache
+ * session and watchdog tables are not recorded.
+ */
+
+// Define default settings.
+$cmd = 'index.php';
+$_SERVER['HTTP_HOST'] = 'default';
+$_SERVER['PHP_SELF'] = '/index.php';
+$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
+$_SERVER['SERVER_SOFTWARE'] = NULL;
+$_SERVER['REQUEST_METHOD'] = 'GET';
+$_SERVER['QUERY_STRING'] = '';
+$_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = '/';
+$_SERVER['HTTP_USER_AGENT'] = 'console';
+
+// Bootstrap Drupal.
+include_once './includes/bootstrap.inc';
+drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+
+// Include the utility drupal_var_export() function.
+include_once dirname(__FILE__) . '/../includes/utility.inc';
+
+// Output the PHP header.
+$output = <<<ENDOFHEADER
+<?php
+
+/**
+ * @file
+ * Filled installation of Drupal 6.17, for test purposes.
+ *
+ * This file was generated by the dump-database-d6.sh tool, from an
+ * installation of Drupal 6, filled with data using the generate-d6-content.sh
+ * tool. It has the following modules installed:
+
+ENDOFHEADER;
+
+foreach (module_list() as $module) {
+ $output .= " * - $module\n";
+}
+$output .= " */\n\n";
+
+// Get the current schema, order it by table name.
+$schema = drupal_get_schema();
+ksort($schema);
+
+// Export all the tables in the schema.
+foreach ($schema as $table => $data) {
+ // Remove descriptions to save time and code.
+ unset($data['description']);
+ foreach ($data['fields'] as &$field) {
+ unset($field['description']);
+ }
+
+ // Dump the table structure.
+ $output .= "db_create_table('" . $table . "', " . drupal_var_export($data) . ");\n";
+
+ // Don't output values for those tables.
+ if (substr($table, 0, 5) == 'cache' || $table == 'sessions' || $table == 'watchdog') {
+ $output .= "\n";
+ continue;
+ }
+
+ // Prepare the export of values.
+ $result = db_query('SELECT * FROM {'. $table .'}');
+ $insert = '';
+ while ($record = db_fetch_array($result)) {
+ // users.uid is a serial and inserting 0 into a serial can break MySQL.
+ // So record uid + 1 instead of uid for every uid and once all records
+ // are in place, fix them up.
+ if ($table == 'users') {
+ $record['uid']++;
+ }
+ $insert .= '->values('. drupal_var_export($record) .")\n";
+ }
+
+ // Dump the values if there are some.
+ if ($insert) {
+ $output .= "db_insert('". $table . "')->fields(". drupal_var_export(array_keys($data['fields'])) .")\n";
+ $output .= $insert;
+ $output .= "->execute();\n";
+ }
+
+ // Add the statement fixing the serial in the user table.
+ if ($table == 'users') {
+ $output .= "db_query('UPDATE {users} SET uid = uid - 1');\n";
+ }
+
+ $output .= "\n";
+}
+
+print $output;
diff --git a/kolab.org/www/drupal-7.26/scripts/dump-database-d7.sh b/kolab.org/www/drupal-7.26/scripts/dump-database-d7.sh
new file mode 100644
index 0000000..7692c40
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/scripts/dump-database-d7.sh
@@ -0,0 +1,90 @@
+#!/usr/bin/env php
+<?php
+
+/**
+ * @file
+ * Dumps a Drupal 7 database into a PHP script to test the upgrade process.
+ *
+ * Run this script at the root of an existing Drupal 7 installation.
+ *
+ * The output of this script is a PHP script that can be run inside Drupal 7
+ * and recreates the Drupal 7 database as dumped. Transient data from cache,
+ * session, and watchdog tables are not recorded.
+ */
+
+// Define default settings.
+define('DRUPAL_ROOT', getcwd());
+$cmd = 'index.php';
+$_SERVER['HTTP_HOST'] = 'default';
+$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
+$_SERVER['SERVER_SOFTWARE'] = NULL;
+$_SERVER['REQUEST_METHOD'] = 'GET';
+$_SERVER['QUERY_STRING'] = '';
+$_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = '/';
+$_SERVER['HTTP_USER_AGENT'] = 'console';
+
+// Bootstrap Drupal.
+include_once './includes/bootstrap.inc';
+drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+
+// Include the utility drupal_var_export() function.
+include_once dirname(__FILE__) . '/../includes/utility.inc';
+
+// Output the PHP header.
+$output = <<<ENDOFHEADER
+<?php
+
+/**
+ * @file
+ * Filled installation of Drupal 7.0, for test purposes.
+ *
+ * This file was generated by the dump-database-d7.sh tool, from an
+ * installation of Drupal 7, filled with data using the generate-d7-content.sh
+ * tool. It has the following modules installed:
+
+ENDOFHEADER;
+
+foreach (module_list() as $module) {
+ $output .= " * - $module\n";
+}
+$output .= " */\n\n";
+
+// Get the current schema, order it by table name.
+$schema = drupal_get_schema();
+ksort($schema);
+
+// Export all the tables in the schema.
+foreach ($schema as $table => $data) {
+ // Remove descriptions to save time and code.
+ unset($data['description']);
+ foreach ($data['fields'] as &$field) {
+ unset($field['description']);
+ }
+
+ // Dump the table structure.
+ $output .= "db_create_table('" . $table . "', " . drupal_var_export($data) . ");\n";
+
+ // Don't output values for those tables.
+ if (substr($table, 0, 5) == 'cache' || $table == 'sessions' || $table == 'watchdog') {
+ $output .= "\n";
+ continue;
+ }
+
+ // Prepare the export of values.
+ $result = db_query('SELECT * FROM {'. $table .'}', array(), array('fetch' => PDO::FETCH_ASSOC));
+ $insert = '';
+ foreach ($result as $record) {
+ $insert .= '->values('. drupal_var_export($record) .")\n";
+ }
+
+ // Dump the values if there are some.
+ if ($insert) {
+ $output .= "db_insert('". $table . "')->fields(". drupal_var_export(array_keys($data['fields'])) .")\n";
+ $output .= $insert;
+ $output .= "->execute();\n";
+ }
+
+ $output .= "\n";
+}
+
+print $output;
diff --git a/kolab.org/www/drupal-7.26/scripts/generate-d6-content.sh b/kolab.org/www/drupal-7.26/scripts/generate-d6-content.sh
new file mode 100644
index 0000000..fc4c68f
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/scripts/generate-d6-content.sh
@@ -0,0 +1,206 @@
+#!/usr/bin/env php
+<?php
+
+/**
+ * Generate content for a Drupal 6 database to test the upgrade process.
+ *
+ * Run this script at the root of an existing Drupal 6 installation.
+ * Steps to use this generation script:
+ * - Install drupal 6.
+ * - Run this script from your Drupal ROOT directory.
+ * - Use the dump-database-d6.sh to generate the D7 file
+ * modules/simpletest/tests/upgrade/database.filled.php
+ */
+
+// Define settings.
+$cmd = 'index.php';
+$_SERVER['HTTP_HOST'] = 'default';
+$_SERVER['PHP_SELF'] = '/index.php';
+$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
+$_SERVER['SERVER_SOFTWARE'] = NULL;
+$_SERVER['REQUEST_METHOD'] = 'GET';
+$_SERVER['QUERY_STRING'] = '';
+$_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = '/';
+$_SERVER['HTTP_USER_AGENT'] = 'console';
+$modules_to_enable = array('path', 'poll');
+
+// Bootstrap Drupal.
+include_once './includes/bootstrap.inc';
+drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+
+// Enable requested modules
+include_once './modules/system/system.admin.inc';
+$form = system_modules();
+foreach ($modules_to_enable as $module) {
+ $form_state['values']['status'][$module] = TRUE;
+}
+$form_state['values']['disabled_modules'] = $form['disabled_modules'];
+system_modules_submit(NULL, $form_state);
+unset($form_state);
+
+// Run cron after installing
+drupal_cron_run();
+
+// Create six users
+for ($i = 0; $i < 6; $i++) {
+ $name = "test user $i";
+ $pass = md5("test PassW0rd $i !(.)");
+ $mail = "test$i@example.com";
+ $now = mktime(0, 0, 0, 1, $i + 1, 2010);
+ db_query("INSERT INTO {users} (name, pass, mail, status, created, access) VALUES ('%s', '%s', '%s', %d, %d, %d)", $name, $pass, $mail, 1, $now, $now);
+}
+
+
+// Create vocabularies and terms
+
+$terms = array();
+
+// All possible combinations of these vocabulary properties.
+$hierarchy = array(0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2);
+$multiple = array(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1);
+$required = array(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1);
+
+$voc_id = 0;
+$term_id = 0;
+for ($i = 0; $i < 24; $i++) {
+ $vocabulary = array();
+ ++$voc_id;
+ $vocabulary['name'] = "vocabulary $voc_id (i=$i)";
+ $vocabulary['description'] = "description of ". $vocabulary['name'];
+ $vocabulary['nodes'] = $i > 11 ? array('page' => TRUE) : array();
+ $vocabulary['multiple'] = $multiple[$i % 12];
+ $vocabulary['required'] = $required[$i % 12];
+ $vocabulary['relations'] = 1;
+ $vocabulary['hierarchy'] = $hierarchy[$i % 12];
+ $vocabulary['weight'] = $i;
+ taxonomy_save_vocabulary($vocabulary);
+ $parents = array();
+ // Vocabularies without hierarchy get one term, single parent vocabularies get
+ // one parent and one child term. Multiple parent vocabularies get three
+ // terms: t0, t1, t2 where t0 is a parent of both t1 and t2.
+ for ($j = 0; $j < $vocabulary['hierarchy'] + 1; $j++) {
+ $term = array();
+ $term['vid'] = $vocabulary['vid'];
+ // For multiple parent vocabularies, omit the t0-t1 relation, otherwise
+ // every parent in the vocabulary is a parent.
+ $term['parent'] = $vocabulary['hierarchy'] == 2 && i == 1 ? array() : $parents;
+ ++$term_id;
+ $term['name'] = "term $term_id of vocabulary $voc_id (j=$j)";
+ $term['description'] = 'description of ' . $term['name'];
+ $term['weight'] = $i * 3 + $j;
+ taxonomy_save_term($term);
+ $terms[] = $term['tid'];
+ $parents[] = $term['tid'];
+ }
+}
+
+$node_id = 0;
+$revision_id = 0;
+module_load_include('inc', 'node', 'node.pages');
+for ($i = 0; $i < 24; $i++) {
+ $uid = intval($i / 8) + 3;
+ $user = user_load($uid);
+ $node = new stdClass();
+ $node->uid = $uid;
+ $node->type = $i < 12 ? 'page' : 'story';
+ $node->sticky = 0;
+ ++$node_id;
+ ++$revision_id;
+ $node->title = "node title $node_id rev $revision_id (i=$i)";
+ $type = node_get_types('type', $node->type);
+ if ($type->has_body) {
+ $node->body = str_repeat("node body ($node->type) - $i", 100);
+ $node->teaser = node_teaser($node->body);
+ $node->filter = variable_get('filter_default_format', 1);
+ $node->format = FILTER_FORMAT_DEFAULT;
+ }
+ $node->status = intval($i / 4) % 2;
+ $node->language = '';
+ $node->revision = $i < 12;
+ $node->promote = $i % 2;
+ $node->created = $now + $i * 86400;
+ $node->log = "added $i node";
+ // Make every term association different a little. For nodes with revisions,
+ // make the initial revision have a different set of terms than the
+ // newest revision.
+ $node_terms = $terms;
+ unset($node_terms[$i], $node_terms[47 - $i]);
+ if ($node->revision) {
+ $node->taxonomy = array($i => $terms[$i], 47-$i => $terms[47 - $i]);
+ }
+ else {
+ $node->taxonomy = $node_terms;
+ }
+ node_save($node);
+ path_set_alias("node/$node->nid", "content/$node->created");
+ if ($node->revision) {
+ $user = user_load($uid + 3);
+ ++$revision_id;
+ $node->title .= " rev2 $revision_id";
+ $node->body = str_repeat("node revision body ($node->type) - $i", 100);
+ $node->log = "added $i revision";
+ $node->taxonomy = $node_terms;
+ node_save($node);
+ }
+}
+
+// Create poll content
+for ($i = 0; $i < 12; $i++) {
+ $uid = intval($i / 4) + 3;
+ $user = user_load($uid);
+ $node = new stdClass();
+ $node->uid = $uid;
+ $node->type = 'poll';
+ $node->sticky = 0;
+ $node->title = "poll title $i";
+ $type = node_get_types('type', $node->type);
+ if ($type->has_body) {
+ $node->body = str_repeat("node body ($node->type) - $i", 100);
+ $node->teaser = node_teaser($node->body);
+ $node->filter = variable_get('filter_default_format', 1);
+ $node->format = FILTER_FORMAT_DEFAULT;
+ }
+ $node->status = intval($i / 2) % 2;
+ $node->language = '';
+ $node->revision = 1;
+ $node->promote = $i % 2;
+ $node->created = $now + $i * 43200;
+ $node->log = "added $i poll";
+
+ $nbchoices = ($i % 4) + 2;
+ for ($c = 0; $c < $nbchoices; $c++) {
+ $node->choice[] = array('chtext' => "Choice $c for poll $i");
+ }
+ node_save($node);
+ path_set_alias("node/$node->nid", "content/poll/$i");
+ path_set_alias("node/$node->nid/results", "content/poll/$i/results");
+
+ // Add some votes
+ for ($v = 0; $v < ($i % 4) + 5; $v++) {
+ $c = $v % $nbchoices;
+ $form_state = array();
+ $form_state['values']['choice'] = $c;
+ $form_state['values']['op'] = t('Vote');
+ 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");
diff --git a/kolab.org/www/drupal-7.26/scripts/generate-d7-content.sh b/kolab.org/www/drupal-7.26/scripts/generate-d7-content.sh
new file mode 100644
index 0000000..1e1d13f
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/scripts/generate-d7-content.sh
@@ -0,0 +1,320 @@
+#!/usr/bin/env php
+<?php
+
+/**
+ * @file
+ * Generates content for a Drupal 7 database to test the upgrade process.
+ *
+ * Run this script at the root of an existing Drupal 6 installation.
+ * Steps to use this generation script:
+ * - Install drupal 7.
+ * - Run this script from your Drupal ROOT directory.
+ * - Use the dump-database-d7.sh to generate the D7 file
+ * modules/simpletest/tests/upgrade/database.filled.php
+ */
+
+// Define settings.
+$cmd = 'index.php';
+define('DRUPAL_ROOT', getcwd());
+$_SERVER['HTTP_HOST'] = 'default';
+$_SERVER['PHP_SELF'] = '/index.php';
+$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
+$_SERVER['SERVER_SOFTWARE'] = NULL;
+$_SERVER['REQUEST_METHOD'] = 'GET';
+$_SERVER['QUERY_STRING'] = '';
+$_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = '/';
+$_SERVER['HTTP_USER_AGENT'] = 'console';
+$modules_to_enable = array('path', 'poll', 'taxonomy');
+
+// Bootstrap Drupal.
+include_once './includes/bootstrap.inc';
+drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+
+// Enable requested modules.
+require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
+include_once './modules/system/system.admin.inc';
+$form = system_modules();
+foreach ($modules_to_enable as $module) {
+ $form_state['values']['status'][$module] = TRUE;
+}
+$form_state['values']['disabled_modules'] = $form['disabled_modules'];
+system_modules_submit(NULL, $form_state);
+unset($form_state);
+
+// Run cron after installing.
+drupal_cron_run();
+
+// Create six users.
+$query = db_insert('users')->fields(array('uid', 'name', 'pass', 'mail', 'status', 'created', 'access'));
+for ($i = 0; $i < 6; $i++) {
+ $name = "test user $i";
+ $pass = md5("test PassW0rd $i !(.)");
+ $mail = "test$i@example.com";
+ $now = mktime(0, 0, 0, 1, $i + 1, 2010);
+ $query->values(array(db_next_id(), $name, user_hash_password($pass), $mail, 1, $now, $now));
+}
+$query->execute();
+
+// Create vocabularies and terms.
+
+if (module_exists('taxonomy')) {
+ $terms = array();
+
+ // All possible combinations of these vocabulary properties.
+ $hierarchy = array(0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2);
+ $multiple = array(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1);
+ $required = array(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1);
+
+ $voc_id = 0;
+ $term_id = 0;
+ for ($i = 0; $i < 24; $i++) {
+ $vocabulary = new stdClass;
+ ++$voc_id;
+ $vocabulary->name = "vocabulary $voc_id (i=$i)";
+ $vocabulary->machine_name = 'vocabulary_' . $voc_id . '_' . $i;
+ $vocabulary->description = "description of ". $vocabulary->name;
+ $vocabulary->multiple = $multiple[$i % 12];
+ $vocabulary->required = $required[$i % 12];
+ $vocabulary->relations = 1;
+ $vocabulary->hierarchy = $hierarchy[$i % 12];
+ $vocabulary->weight = $i;
+ taxonomy_vocabulary_save($vocabulary);
+ $field = array(
+ 'field_name' => 'taxonomy_'. $vocabulary->machine_name,
+ 'module' => 'taxonomy',
+ 'type' => 'taxonomy_term_reference',
+ 'cardinality' => $vocabulary->multiple || $vocabulary->tags ? FIELD_CARDINALITY_UNLIMITED : 1,
+ 'settings' => array(
+ 'required' => $vocabulary->required ? TRUE : FALSE,
+ 'allowed_values' => array(
+ array(
+ 'vocabulary' => $vocabulary->machine_name,
+ 'parent' => 0,
+ ),
+ ),
+ ),
+ );
+ field_create_field($field);
+ $node_types = $i > 11 ? array('page') : array_keys(node_type_get_types());
+ foreach ($node_types as $bundle) {
+ $instance = array(
+ 'label' => $vocabulary->name,
+ 'field_name' => $field['field_name'],
+ 'bundle' => $bundle,
+ 'entity_type' => 'node',
+ 'settings' => array(),
+ 'description' => $vocabulary->help,
+ 'required' => $vocabulary->required,
+ 'widget' => array(),
+ 'display' => array(
+ 'default' => array(
+ 'type' => 'taxonomy_term_reference_link',
+ 'weight' => 10,
+ ),
+ 'teaser' => array(
+ 'type' => 'taxonomy_term_reference_link',
+ 'weight' => 10,
+ ),
+ ),
+ );
+ if ($vocabulary->tags) {
+ $instance['widget'] = array(
+ 'type' => 'taxonomy_autocomplete',
+ 'module' => 'taxonomy',
+ 'settings' => array(
+ 'size' => 60,
+ 'autocomplete_path' => 'taxonomy/autocomplete',
+ ),
+ );
+ }
+ else {
+ $instance['widget'] = array(
+ 'type' => 'options_select',
+ 'settings' => array(),
+ );
+ }
+ field_create_instance($instance);
+ }
+ $parents = array();
+ // Vocabularies without hierarchy get one term; single parent vocabularies
+ // get one parent and one child term. Multiple parent vocabularies get
+ // three terms: t0, t1, t2 where t0 is a parent of both t1 and t2.
+ for ($j = 0; $j < $vocabulary->hierarchy + 1; $j++) {
+ $term = new stdClass;
+ $term->vocabulary_machine_name = $vocabulary->machine_name;
+ // For multiple parent vocabularies, omit the t0-t1 relation, otherwise
+ // every parent in the vocabulary is a parent.
+ $term->parent = $vocabulary->hierarchy == 2 && i == 1 ? array() : $parents;
+ ++$term_id;
+ $term->name = "term $term_id of vocabulary $voc_id (j=$j)";
+ $term->description = 'description of ' . $term->name;
+ $term->format = 'filtered_html';
+ $term->weight = $i * 3 + $j;
+ taxonomy_term_save($term);
+ $terms[] = $term->tid;
+ $term_vocabs[$term->tid] = 'taxonomy_' . $vocabulary->machine_name;
+ $parents[] = $term->tid;
+ }
+ }
+}
+
+$node_id = 0;
+$revision_id = 0;
+module_load_include('inc', 'node', 'node.pages');
+for ($i = 0; $i < 24; $i++) {
+ $uid = intval($i / 8) + 3;
+ $user = user_load($uid);
+ $node = new stdClass();
+ $node->uid = $uid;
+ $node->type = $i < 12 ? 'page' : 'story';
+ $node->sticky = 0;
+ ++$node_id;
+ ++$revision_id;
+ $node->title = "node title $node_id rev $revision_id (i=$i)";
+ $node->language = LANGUAGE_NONE;
+ $body_text = str_repeat("node body ($node->type) - $i", 100);
+ $node->body[$node->language][0]['value'] = $body_text;
+ $node->body[$node->language][0]['summary'] = text_summary($body_text);
+ $node->body[$node->language][0]['format'] = 'filtered_html';
+ $node->status = intval($i / 4) % 2;
+ $node->revision = $i < 12;
+ $node->promote = $i % 2;
+ $node->created = $now + $i * 86400;
+ $node->log = "added $i node";
+ // Make every term association different a little. For nodes with revisions,
+ // make the initial revision have a different set of terms than the
+ // newest revision.
+ $items = array();
+ if (module_exists('taxonomy')) {
+ if ($node->revision) {
+ $node_terms = array($terms[$i], $terms[47-$i]);
+ }
+ else {
+ $node_terms = $terms;
+ unset($node_terms[$i], $node_terms[47 - $i]);
+ }
+ foreach ($node_terms as $tid) {
+ $field_name = $term_vocabs[$tid];
+ $node->{$field_name}[LANGUAGE_NONE][] = array('tid' => $tid);
+ }
+ }
+ $node->path = array('alias' => "content/$node->created");
+ node_save($node);
+ if ($node->revision) {
+ $user = user_load($uid + 3);
+ ++$revision_id;
+ $node->title .= " rev2 $revision_id";
+ $body_text = str_repeat("node revision body ($node->type) - $i", 100);
+ $node->body[$node->language][0]['value'] = $body_text;
+ $node->body[$node->language][0]['summary'] = text_summary($body_text);
+ $node->body[$node->language][0]['format'] = 'filtered_html';
+ $node->log = "added $i revision";
+ $node_terms = $terms;
+ unset($node_terms[$i], $node_terms[47 - $i]);
+ foreach ($node_terms as $tid) {
+ $field_name = $term_vocabs[$tid];
+ $node->{$field_name}[LANGUAGE_NONE][] = array('tid' => $tid);
+ }
+ node_save($node);
+ }
+}
+
+if (module_exists('poll')) {
+ // Create poll content.
+ for ($i = 0; $i < 12; $i++) {
+ $uid = intval($i / 4) + 3;
+ $user = user_load($uid);
+ $node = new stdClass();
+ $node->uid = $uid;
+ $node->type = 'poll';
+ $node->sticky = 0;
+ $node->title = "poll title $i";
+ $node->language = LANGUAGE_NONE;
+ $node->status = intval($i / 2) % 2;
+ $node->revision = 1;
+ $node->promote = $i % 2;
+ $node->created = REQUEST_TIME + $i * 43200;
+ $node->runtime = 0;
+ $node->active = 1;
+ $node->log = "added $i poll";
+ $node->path = array('alias' => "content/poll/$i");
+
+ $nbchoices = ($i % 4) + 2;
+ for ($c = 0; $c < $nbchoices; $c++) {
+ $node->choice[] = array('chtext' => "Choice $c for poll $i", 'chvotes' => 0, 'weight' => 0);
+ }
+ node_save($node);
+ $path = array(
+ 'alias' => "content/poll/$i/results",
+ 'source' => "node/$node->nid/results",
+ );
+ path_save($path);
+
+ // Add some votes.
+ $node = node_load($node->nid);
+ $choices = array_keys($node->choice);
+ $original_user = $GLOBALS['user'];
+ for ($v = 0; $v < ($i % 4); $v++) {
+ drupal_static_reset('ip_address');
+ $_SERVER['REMOTE_ADDR'] = "127.0.$v.1";
+ $GLOBALS['user'] = drupal_anonymous_user();// We should have already allowed anon to vote.
+ $c = $v % $nbchoices;
+ $form_state = array();
+ $form_state['values']['choice'] = $choices[$c];
+ $form_state['values']['op'] = t('Vote');
+ drupal_form_submit('poll_view_voting', $form_state, $node);
+ }
+ }
+}
+
+// Test that upgrade works even on a bundle whose parent module was disabled.
+// This is simulated by creating an existing content type and changing the
+// bundle to another type through direct database update queries.
+$node_type = 'broken';
+$uid = 6;
+$user = user_load($uid);
+$node = new stdClass();
+$node->uid = $uid;
+$node->type = 'article';
+$body_text = str_repeat("node body ($node_type) - 37", 100);
+$node->sticky = 0;
+$node->title = "node title 24";
+$node->language = LANGUAGE_NONE;
+$node->body[$node->language][0]['value'] = $body_text;
+$node->body[$node->language][0]['summary'] = text_summary($body_text);
+$node->body[$node->language][0]['format'] = 'filtered_html';
+$node->status = 1;
+$node->revision = 0;
+$node->promote = 0;
+$node->created = 1263769200;
+$node->log = "added a broken node";
+$node->path = array('alias' => "content/1263769200");
+node_save($node);
+db_update('node')
+ ->fields(array(
+ 'type' => $node_type,
+ ))
+ ->condition('nid', $node->nid)
+ ->execute();
+if (db_table_exists('field_data_body')) {
+ db_update('field_data_body')
+ ->fields(array(
+ 'bundle' => $node_type,
+ ))
+ ->condition('entity_id', $node->nid)
+ ->condition('entity_type', 'node')
+ ->execute();
+ db_update('field_revision_body')
+ ->fields(array(
+ 'bundle' => $node_type,
+ ))
+ ->condition('entity_id', $node->nid)
+ ->condition('entity_type', 'node')
+ ->execute();
+}
+db_update('field_config_instance')
+ ->fields(array(
+ 'bundle' => $node_type,
+ ))
+ ->condition('bundle', 'article')
+ ->execute();
diff --git a/kolab.org/www/drupal-7.26/scripts/password-hash.sh b/kolab.org/www/drupal-7.26/scripts/password-hash.sh
new file mode 100755
index 0000000..004421a
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/scripts/password-hash.sh
@@ -0,0 +1,90 @@
+#!/usr/bin/php
+<?php
+
+/**
+ * Drupal hash script - to generate a hash from a plaintext password
+ *
+ * Check for your PHP interpreter - on Windows you'll probably have to
+ * replace line 1 with
+ * #!c:/program files/php/php.exe
+ *
+ * @param password1 [password2 [password3 ...]]
+ * Plain-text passwords in quotes (or with spaces backslash escaped).
+ */
+
+if (version_compare(PHP_VERSION, "5.2.0", "<")) {
+ $version = PHP_VERSION;
+ echo <<<EOF
+
+ERROR: This script requires at least PHP version 5.2.0. You invoked it with
+ PHP version {$version}.
+\n
+EOF;
+ exit;
+}
+
+$script = basename(array_shift($_SERVER['argv']));
+
+if (in_array('--help', $_SERVER['argv']) || empty($_SERVER['argv'])) {
+ echo <<<EOF
+
+Generate Drupal password hashes from the shell.
+
+Usage: {$script} [OPTIONS] "<plan-text password>"
+Example: {$script} "mynewpassword"
+
+All arguments are long options.
+
+ --help Print this page.
+
+ --root <path>
+
+ Set the working directory for the script to the specified path.
+ To execute this script this has to be the root directory of your
+ Drupal installation, e.g. /home/www/foo/drupal (assuming Drupal
+ running on Unix). Use surrounding quotation marks on Windows.
+
+ "<password1>" ["<password2>" ["<password3>" ...]]
+
+ One or more plan-text passwords enclosed by double quotes. The
+ output hash may be manually entered into the {users}.pass field to
+ change a password via SQL to a known value.
+
+To run this script without the --root argument invoke it from the root directory
+of your Drupal installation as
+
+ ./scripts/{$script}
+\n
+EOF;
+ exit;
+}
+
+$passwords = array();
+
+// Parse invocation arguments.
+while ($param = array_shift($_SERVER['argv'])) {
+ switch ($param) {
+ case '--root':
+ // Change the working directory.
+ $path = array_shift($_SERVER['argv']);
+ if (is_dir($path)) {
+ chdir($path);
+ }
+ break;
+ default:
+ // Add a password to the list to be processed.
+ $passwords[] = $param;
+ break;
+ }
+}
+
+define('DRUPAL_ROOT', getcwd());
+
+include_once DRUPAL_ROOT . '/includes/password.inc';
+include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
+
+foreach ($passwords as $password) {
+ print("\npassword: $password \t\thash: ". user_hash_password($password) ."\n");
+}
+print("\n");
+
diff --git a/kolab.org/www/drupal-7.26/scripts/run-tests.sh b/kolab.org/www/drupal-7.26/scripts/run-tests.sh
new file mode 100755
index 0000000..189d7f2
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/scripts/run-tests.sh
@@ -0,0 +1,676 @@
+<?php
+/**
+ * @file
+ * This script runs Drupal tests from command line.
+ */
+
+define('SIMPLETEST_SCRIPT_COLOR_PASS', 32); // Green.
+define('SIMPLETEST_SCRIPT_COLOR_FAIL', 31); // Red.
+define('SIMPLETEST_SCRIPT_COLOR_EXCEPTION', 33); // Brown.
+
+// Set defaults and get overrides.
+list($args, $count) = simpletest_script_parse_args();
+
+if ($args['help'] || $count == 0) {
+ simpletest_script_help();
+ exit;
+}
+
+if ($args['execute-test']) {
+ // Masquerade as Apache for running tests.
+ simpletest_script_init("Apache");
+ simpletest_script_run_one_test($args['test-id'], $args['execute-test']);
+}
+else {
+ // Run administrative functions as CLI.
+ simpletest_script_init(NULL);
+}
+
+// Bootstrap to perform initial validation or other operations.
+drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+if (!module_exists('simpletest')) {
+ simpletest_script_print_error("The simpletest module must be enabled before this script can run.");
+ exit;
+}
+
+if ($args['clean']) {
+ // Clean up left-over times and directories.
+ simpletest_clean_environment();
+ echo "\nEnvironment cleaned.\n";
+
+ // Get the status messages and print them.
+ $messages = array_pop(drupal_get_messages('status'));
+ foreach ($messages as $text) {
+ echo " - " . $text . "\n";
+ }
+ exit;
+}
+
+// Load SimpleTest files.
+$groups = simpletest_test_get_all();
+$all_tests = array();
+foreach ($groups as $group => $tests) {
+ $all_tests = array_merge($all_tests, array_keys($tests));
+}
+$test_list = array();
+
+if ($args['list']) {
+ // Display all available tests.
+ echo "\nAvailable test groups & classes\n";
+ echo "-------------------------------\n\n";
+ foreach ($groups as $group => $tests) {
+ echo $group . "\n";
+ foreach ($tests as $class => $info) {
+ echo " - " . $info['name'] . ' (' . $class . ')' . "\n";
+ }
+ }
+ exit;
+}
+
+$test_list = simpletest_script_get_test_list();
+
+// Try to allocate unlimited time to run the tests.
+drupal_set_time_limit(0);
+
+simpletest_script_reporter_init();
+
+// Setup database for test results.
+$test_id = db_insert('simpletest_test_id')->useDefaults(array('test_id'))->execute();
+
+// Execute tests.
+simpletest_script_execute_batch($test_id, simpletest_script_get_test_list());
+
+// Retrieve the last database prefix used for testing and the last test class
+// that was run from. Use the information to read the lgo file in case any
+// fatal errors caused the test to crash.
+list($last_prefix, $last_test_class) = simpletest_last_test_get($test_id);
+simpletest_log_read($test_id, $last_prefix, $last_test_class);
+
+// Stop the timer.
+simpletest_script_reporter_timer_stop();
+
+// Display results before database is cleared.
+simpletest_script_reporter_display_results();
+
+if ($args['xml']) {
+ simpletest_script_reporter_write_xml_results();
+}
+
+// Cleanup our test results.
+simpletest_clean_results_table($test_id);
+
+// Test complete, exit.
+exit;
+
+/**
+ * Print help text.
+ */
+function simpletest_script_help() {
+ global $args;
+
+ echo <<<EOF
+
+Run Drupal tests from the shell.
+
+Usage: {$args['script']} [OPTIONS] <tests>
+Example: {$args['script']} Profile
+
+All arguments are long options.
+
+ --help Print this page.
+
+ --list Display all available test groups.
+
+ --clean Cleans up database tables or directories from previous, failed,
+ tests and then exits (no tests are run).
+
+ --url Immediately precedes a URL to set the host and path. You will
+ need this parameter if Drupal is in a subdirectory on your
+ localhost and you have not set \$base_url in settings.php. Tests
+ can be run under SSL by including https:// in the URL.
+
+ --php The absolute path to the PHP executable. Usually not needed.
+
+ --concurrency [num]
+
+ Run tests in parallel, up to [num] tests at a time.
+
+ --all Run all available tests.
+
+ --class Run tests identified by specific class names, instead of group names.
+
+ --file Run tests identified by specific file names, instead of group names.
+ Specify the path and the extension (i.e. 'modules/user/user.test').
+
+ --xml <path>
+
+ If provided, test results will be written as xml files to this path.
+
+ --color Output text format results with color highlighting.
+
+ --verbose Output detailed assertion messages in addition to summary.
+
+ <test1>[,<test2>[,<test3> ...]]
+
+ One or more tests to be run. By default, these are interpreted
+ as the names of test groups as shown at
+ ?q=admin/config/development/testing.
+ These group names typically correspond to module names like "User"
+ or "Profile" or "System", but there is also a group "XML-RPC".
+ If --class is specified then these are interpreted as the names of
+ specific test classes whose test methods will be run. Tests must
+ be separated by commas. Ignored if --all is specified.
+
+To run this script you will normally invoke it from the root directory of your
+Drupal installation as the webserver user (differs per configuration), or root:
+
+sudo -u [wwwrun|www-data|etc] php ./scripts/{$args['script']}
+ --url http://example.com/ --all
+sudo -u [wwwrun|www-data|etc] php ./scripts/{$args['script']}
+ --url http://example.com/ --class BlockTestCase
+\n
+EOF;
+}
+
+/**
+ * Parse execution argument and ensure that all are valid.
+ *
+ * @return The list of arguments.
+ */
+function simpletest_script_parse_args() {
+ // Set default values.
+ $args = array(
+ 'script' => '',
+ 'help' => FALSE,
+ 'list' => FALSE,
+ 'clean' => FALSE,
+ 'url' => '',
+ 'php' => '',
+ 'concurrency' => 1,
+ 'all' => FALSE,
+ 'class' => FALSE,
+ 'file' => FALSE,
+ 'color' => FALSE,
+ 'verbose' => FALSE,
+ 'test_names' => array(),
+ // Used internally.
+ 'test-id' => 0,
+ 'execute-test' => '',
+ 'xml' => '',
+ );
+
+ // Override with set values.
+ $args['script'] = basename(array_shift($_SERVER['argv']));
+
+ $count = 0;
+ while ($arg = array_shift($_SERVER['argv'])) {
+ if (preg_match('/--(\S+)/', $arg, $matches)) {
+ // Argument found.
+ if (array_key_exists($matches[1], $args)) {
+ // Argument found in list.
+ $previous_arg = $matches[1];
+ if (is_bool($args[$previous_arg])) {
+ $args[$matches[1]] = TRUE;
+ }
+ else {
+ $args[$matches[1]] = array_shift($_SERVER['argv']);
+ }
+ // Clear extraneous values.
+ $args['test_names'] = array();
+ $count++;
+ }
+ else {
+ // Argument not found in list.
+ simpletest_script_print_error("Unknown argument '$arg'.");
+ exit;
+ }
+ }
+ else {
+ // Values found without an argument should be test names.
+ $args['test_names'] += explode(',', $arg);
+ $count++;
+ }
+ }
+
+ // Validate the concurrency argument
+ if (!is_numeric($args['concurrency']) || $args['concurrency'] <= 0) {
+ simpletest_script_print_error("--concurrency must be a strictly positive integer.");
+ exit;
+ }
+
+ return array($args, $count);
+}
+
+/**
+ * Initialize script variables and perform general setup requirements.
+ */
+function simpletest_script_init($server_software) {
+ global $args, $php;
+
+ $host = 'localhost';
+ $path = '';
+ // Determine location of php command automatically, unless a command line argument is supplied.
+ if (!empty($args['php'])) {
+ $php = $args['php'];
+ }
+ elseif ($php_env = getenv('_')) {
+ // '_' is an environment variable set by the shell. It contains the command that was executed.
+ $php = $php_env;
+ }
+ elseif ($sudo = getenv('SUDO_COMMAND')) {
+ // 'SUDO_COMMAND' is an environment variable set by the sudo program.
+ // Extract only the PHP interpreter, not the rest of the command.
+ list($php, ) = explode(' ', $sudo, 2);
+ }
+ else {
+ simpletest_script_print_error('Unable to automatically determine the path to the PHP interpreter. Supply the --php command line argument.');
+ simpletest_script_help();
+ exit();
+ }
+
+ // Get URL from arguments.
+ if (!empty($args['url'])) {
+ $parsed_url = parse_url($args['url']);
+ $host = $parsed_url['host'] . (isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '');
+ $path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
+
+ // If the passed URL schema is 'https' then setup the $_SERVER variables
+ // properly so that testing will run under HTTPS.
+ if ($parsed_url['scheme'] == 'https') {
+ $_SERVER['HTTPS'] = 'on';
+ }
+ }
+
+ $_SERVER['HTTP_HOST'] = $host;
+ $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
+ $_SERVER['SERVER_ADDR'] = '127.0.0.1';
+ $_SERVER['SERVER_SOFTWARE'] = $server_software;
+ $_SERVER['SERVER_NAME'] = 'localhost';
+ $_SERVER['REQUEST_URI'] = $path .'/';
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $_SERVER['SCRIPT_NAME'] = $path .'/index.php';
+ $_SERVER['PHP_SELF'] = $path .'/index.php';
+ $_SERVER['HTTP_USER_AGENT'] = 'Drupal command line';
+
+ if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
+ // Ensure that any and all environment variables are changed to https://.
+ foreach ($_SERVER as $key => $value) {
+ $_SERVER[$key] = str_replace('http://', 'https://', $_SERVER[$key]);
+ }
+ }
+
+ chdir(realpath(dirname(__FILE__) . '/..'));
+ define('DRUPAL_ROOT', getcwd());
+ require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
+}
+
+/**
+ * Execute a batch of tests.
+ */
+function simpletest_script_execute_batch($test_id, $test_classes) {
+ global $args;
+
+ // Multi-process execution.
+ $children = array();
+ while (!empty($test_classes) || !empty($children)) {
+ while (count($children) < $args['concurrency']) {
+ if (empty($test_classes)) {
+ break;
+ }
+
+ // Fork a child process.
+ $test_class = array_shift($test_classes);
+ $command = simpletest_script_command($test_id, $test_class);
+ $process = proc_open($command, array(), $pipes, NULL, NULL, array('bypass_shell' => TRUE));
+
+ if (!is_resource($process)) {
+ echo "Unable to fork test process. Aborting.\n";
+ exit;
+ }
+
+ // Register our new child.
+ $children[] = array(
+ 'process' => $process,
+ 'class' => $test_class,
+ 'pipes' => $pipes,
+ );
+ }
+
+ // Wait for children every 200ms.
+ usleep(200000);
+
+ // Check if some children finished.
+ foreach ($children as $cid => $child) {
+ $status = proc_get_status($child['process']);
+ if (empty($status['running'])) {
+ // The child exited, unregister it.
+ proc_close($child['process']);
+ if ($status['exitcode']) {
+ echo 'FATAL ' . $test_class . ': test runner returned a non-zero error code (' . $status['exitcode'] . ').' . "\n";
+ }
+ unset($children[$cid]);
+ }
+ }
+ }
+}
+
+/**
+ * Bootstrap Drupal and run a single test.
+ */
+function simpletest_script_run_one_test($test_id, $test_class) {
+ try {
+ // Bootstrap Drupal.
+ drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+
+ simpletest_classloader_register();
+
+ $test = new $test_class($test_id);
+ $test->run();
+ $info = $test->getInfo();
+
+ $had_fails = (isset($test->results['#fail']) && $test->results['#fail'] > 0);
+ $had_exceptions = (isset($test->results['#exception']) && $test->results['#exception'] > 0);
+ $status = ($had_fails || $had_exceptions ? 'fail' : 'pass');
+ simpletest_script_print($info['name'] . ' ' . _simpletest_format_summary_line($test->results) . "\n", simpletest_script_color_code($status));
+
+ // Finished, kill this runner.
+ exit(0);
+ }
+ catch (Exception $e) {
+ echo (string) $e;
+ exit(1);
+ }
+}
+
+/**
+ * Return a command used to run a test in a separate process.
+ *
+ * @param $test_id
+ * The current test ID.
+ * @param $test_class
+ * The name of the test class to run.
+ */
+function simpletest_script_command($test_id, $test_class) {
+ global $args, $php;
+
+ $command = escapeshellarg($php) . ' ' . escapeshellarg('./scripts/' . $args['script']) . ' --url ' . escapeshellarg($args['url']);
+ if ($args['color']) {
+ $command .= ' --color';
+ }
+ $command .= " --php " . escapeshellarg($php) . " --test-id $test_id --execute-test " . escapeshellarg($test_class);
+ return $command;
+}
+
+/**
+ * Get list of tests based on arguments. If --all specified then
+ * returns all available tests, otherwise reads list of tests.
+ *
+ * Will print error and exit if no valid tests were found.
+ *
+ * @return List of tests.
+ */
+function simpletest_script_get_test_list() {
+ global $args, $all_tests, $groups;
+
+ $test_list = array();
+ if ($args['all']) {
+ $test_list = $all_tests;
+ }
+ else {
+ if ($args['class']) {
+ // Check for valid class names.
+ foreach ($args['test_names'] as $class_name) {
+ if (in_array($class_name, $all_tests)) {
+ $test_list[] = $class_name;
+ }
+ }
+ }
+ elseif ($args['file']) {
+ $files = array();
+ foreach ($args['test_names'] as $file) {
+ $files[drupal_realpath($file)] = 1;
+ }
+
+ // Check for valid class names.
+ foreach ($all_tests as $class_name) {
+ $refclass = new ReflectionClass($class_name);
+ $file = $refclass->getFileName();
+ if (isset($files[$file])) {
+ $test_list[] = $class_name;
+ }
+ }
+ }
+ else {
+ // Check for valid group names and get all valid classes in group.
+ foreach ($args['test_names'] as $group_name) {
+ if (isset($groups[$group_name])) {
+ foreach ($groups[$group_name] as $class_name => $info) {
+ $test_list[] = $class_name;
+ }
+ }
+ }
+ }
+ }
+
+ if (empty($test_list)) {
+ simpletest_script_print_error('No valid tests were specified.');
+ exit;
+ }
+ return $test_list;
+}
+
+/**
+ * Initialize the reporter.
+ */
+function simpletest_script_reporter_init() {
+ global $args, $all_tests, $test_list, $results_map;
+
+ $results_map = array(
+ 'pass' => 'Pass',
+ 'fail' => 'Fail',
+ 'exception' => 'Exception'
+ );
+
+ echo "\n";
+ echo "Drupal test run\n";
+ echo "---------------\n";
+ echo "\n";
+
+ // Tell the user about what tests are to be run.
+ if ($args['all']) {
+ echo "All tests will run.\n\n";
+ }
+ else {
+ echo "Tests to be run:\n";
+ foreach ($test_list as $class_name) {
+ $info = call_user_func(array($class_name, 'getInfo'));
+ echo " - " . $info['name'] . ' (' . $class_name . ')' . "\n";
+ }
+ echo "\n";
+ }
+
+ echo "Test run started:\n";
+ echo " " . format_date($_SERVER['REQUEST_TIME'], 'long') . "\n";
+ timer_start('run-tests');
+ echo "\n";
+
+ echo "Test summary\n";
+ echo "------------\n";
+ echo "\n";
+}
+
+/**
+ * Display jUnit XML test results.
+ */
+function simpletest_script_reporter_write_xml_results() {
+ global $args, $test_id, $results_map;
+
+ $results = db_query("SELECT * FROM {simpletest} WHERE test_id = :test_id ORDER BY test_class, message_id", array(':test_id' => $test_id));
+
+ $test_class = '';
+ $xml_files = array();
+
+ foreach ($results as $result) {
+ if (isset($results_map[$result->status])) {
+ if ($result->test_class != $test_class) {
+ // We've moved onto a new class, so write the last classes results to a file:
+ if (isset($xml_files[$test_class])) {
+ file_put_contents($args['xml'] . '/' . $test_class . '.xml', $xml_files[$test_class]['doc']->saveXML());
+ unset($xml_files[$test_class]);
+ }
+ $test_class = $result->test_class;
+ if (!isset($xml_files[$test_class])) {
+ $doc = new DomDocument('1.0');
+ $root = $doc->createElement('testsuite');
+ $root = $doc->appendChild($root);
+ $xml_files[$test_class] = array('doc' => $doc, 'suite' => $root);
+ }
+ }
+
+ // For convenience:
+ $dom_document = &$xml_files[$test_class]['doc'];
+
+ // Create the XML element for this test case:
+ $case = $dom_document->createElement('testcase');
+ $case->setAttribute('classname', $test_class);
+ list($class, $name) = explode('->', $result->function, 2);
+ $case->setAttribute('name', $name);
+
+ // Passes get no further attention, but failures and exceptions get to add more detail:
+ if ($result->status == 'fail') {
+ $fail = $dom_document->createElement('failure');
+ $fail->setAttribute('type', 'failure');
+ $fail->setAttribute('message', $result->message_group);
+ $text = $dom_document->createTextNode($result->message);
+ $fail->appendChild($text);
+ $case->appendChild($fail);
+ }
+ elseif ($result->status == 'exception') {
+ // In the case of an exception the $result->function may not be a class
+ // method so we record the full function name:
+ $case->setAttribute('name', $result->function);
+
+ $fail = $dom_document->createElement('error');
+ $fail->setAttribute('type', 'exception');
+ $fail->setAttribute('message', $result->message_group);
+ $full_message = $result->message . "\n\nline: " . $result->line . "\nfile: " . $result->file;
+ $text = $dom_document->createTextNode($full_message);
+ $fail->appendChild($text);
+ $case->appendChild($fail);
+ }
+ // Append the test case XML to the test suite:
+ $xml_files[$test_class]['suite']->appendChild($case);
+ }
+ }
+ // The last test case hasn't been saved to a file yet, so do that now:
+ if (isset($xml_files[$test_class])) {
+ file_put_contents($args['xml'] . '/' . $test_class . '.xml', $xml_files[$test_class]['doc']->saveXML());
+ unset($xml_files[$test_class]);
+ }
+}
+
+/**
+ * Stop the test timer.
+ */
+function simpletest_script_reporter_timer_stop() {
+ echo "\n";
+ $end = timer_stop('run-tests');
+ echo "Test run duration: " . format_interval($end['time'] / 1000);
+ echo "\n\n";
+}
+
+/**
+ * Display test results.
+ */
+function simpletest_script_reporter_display_results() {
+ global $args, $test_id, $results_map;
+
+ if ($args['verbose']) {
+ // Report results.
+ echo "Detailed test results\n";
+ echo "---------------------\n";
+
+ $results = db_query("SELECT * FROM {simpletest} WHERE test_id = :test_id ORDER BY test_class, message_id", array(':test_id' => $test_id));
+ $test_class = '';
+ foreach ($results as $result) {
+ if (isset($results_map[$result->status])) {
+ if ($result->test_class != $test_class) {
+ // Display test class every time results are for new test class.
+ echo "\n\n---- $result->test_class ----\n\n\n";
+ $test_class = $result->test_class;
+
+ // Print table header.
+ echo "Status Group Filename Line Function \n";
+ echo "--------------------------------------------------------------------------------\n";
+ }
+
+ simpletest_script_format_result($result);
+ }
+ }
+ }
+}
+
+/**
+ * Format the result so that it fits within the default 80 character
+ * terminal size.
+ *
+ * @param $result The result object to format.
+ */
+function simpletest_script_format_result($result) {
+ global $results_map, $color;
+
+ $summary = sprintf("%-9.9s %-10.10s %-17.17s %4.4s %-35.35s\n",
+ $results_map[$result->status], $result->message_group, basename($result->file), $result->line, $result->function);
+
+ simpletest_script_print($summary, simpletest_script_color_code($result->status));
+
+ $lines = explode("\n", wordwrap(trim(strip_tags($result->message)), 76));
+ foreach ($lines as $line) {
+ echo " $line\n";
+ }
+}
+
+/**
+ * Print error message prefixed with " ERROR: " and displayed in fail color
+ * if color output is enabled.
+ *
+ * @param $message The message to print.
+ */
+function simpletest_script_print_error($message) {
+ simpletest_script_print(" ERROR: $message\n", SIMPLETEST_SCRIPT_COLOR_FAIL);
+}
+
+/**
+ * Print a message to the console, if color is enabled then the specified
+ * color code will be used.
+ *
+ * @param $message The message to print.
+ * @param $color_code The color code to use for coloring.
+ */
+function simpletest_script_print($message, $color_code) {
+ global $args;
+ if ($args['color']) {
+ echo "\033[" . $color_code . "m" . $message . "\033[0m";
+ }
+ else {
+ echo $message;
+ }
+}
+
+/**
+ * Get the color code associated with the specified status.
+ *
+ * @param $status The status string to get code for.
+ * @return Color code.
+ */
+function simpletest_script_color_code($status) {
+ switch ($status) {
+ case 'pass':
+ return SIMPLETEST_SCRIPT_COLOR_PASS;
+ case 'fail':
+ return SIMPLETEST_SCRIPT_COLOR_FAIL;
+ case 'exception':
+ return SIMPLETEST_SCRIPT_COLOR_EXCEPTION;
+ }
+ return 0; // Default formatting.
+}
diff --git a/kolab.org/www/drupal-7.26/scripts/test.script b/kolab.org/www/drupal-7.26/scripts/test.script
new file mode 100644
index 0000000..a45f3f0
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/scripts/test.script
@@ -0,0 +1,4 @@
+This file is for testing purposes only.
+
+It is used to test the functionality of drupal_get_filename(). See
+BootstrapGetFilenameTestCase::testDrupalGetFilename() for more information.