#!/bin/bash set -ex ## Setup a Drupal site with CiviCRM configured for unit-testing. ## If a site already exists, destroy and recreate it. ## Usage: mk-drupal-test-site ## SOURCE: ## https://github.com/civicrm/civicrm-core/blob/master/tools/scripts/mk-drupal-test-site ## Pre-requisites: ## - MySQL admin credentials in ~/.my.cnf ## - Apache vhost with mod_rewrite, etc ## - DNS or /etc/hosts entries for "url" ## - Drupal source tree ## - CiviCRM source tree (outside the drupal root) ## - makepasswd ## - drush ## - (strongly recommended) filesystem with "acl" support function usage() { cat < "sites/$SITE_URL/civicrm.settings.php" echo >> "sites/$SITE_URL/civicrm.settings.php" echo "define('CIVICRM_MAIL_LOG', '/dev/null');" >> "sites/$SITE_URL/civicrm.settings.php" popd ## Create CiviCRM config cat > "$CIVI_ROOT/bin/setup.conf" << EOF SVNROOT="$CIVI_ROOT" CIVISOURCEDIR="$CIVI_ROOT" SCHEMA=schema/Schema.xml DBNAME="$DB_NAME" DBUSER="$DB_USER" DBPASS="$DB_PASS" DBARGS="" PHP5PATH= DBLOAD="$DBLOAD" # DBADD= EOF cat > "$CIVI_ROOT/tests/phpunit/CiviTest/civicrm.settings.local.php" << EOF "$CIVI_ROOT/tests/phpunit/CiviTest/CiviSeleniumSettings.php" << EOF fullSandboxPath = \$this->sandboxURL . \$this->sandboxPATH; } } EOF pushd "$CIVI_ROOT" ./bin/setup.sh popd if [ -n "$SQL_DUMP" ]; then echo "Importing SQL dump: $SQL_DUMP" mysql $DB_NAME < "$SQL_DUMP" echo "SQL import complete." if [ -n "$SQL_DUMP2" -a -f "$SQL_DUMP2" ]; then echo "Importing SQL dump: $SQL_DUMP2" mysql $DB_NAME < "$SQL_DUMP2" echo "SQL import complete." fi else pushd "$DRUPAL_ROOT" drush -l "${SITE_URL}" -y pm-enable civicrm drush -l "${SITE_URL}" -y pm-enable civicrm_webtest drush -l "${SITE_URL}" -y user-create --password=demo --mail='demo@example.com' demo drush -l "${SITE_URL}" -y user-add-role civicrm_webtest_user demo popd fi