<?php
+define('CIVICRM_TEST', 1);
+
// This file is loaded on all systems running tests. To override settings on
// your local system, please create "civicrm.settings.local.php" and put
// the settings there.
//--- you shouldn't have to modify anything under this line, but might want to put the compiled templates CIVICRM_TEMPLATE_COMPILEDIR in a different folder than our default location ----------
-if ( ! defined( 'CIVICRM_DSN' ) && ! empty( $GLOBALS['mysql_user'] ) ) {
- $dbName = ! empty( $GLOBALS['mysql_db'] ) ? $GLOBALS['mysql_db'] : 'civicrm_tests_dev';
- if ( empty( $GLOBALS['mysql_pass'] ) && $GLOBALS['mysql_pass_need_password'] ) {
- $GLOBALS['mysql_pass'] = PHPUnit_TextUI_Command::getPassword( 'Password' );
+if (!defined('CIVICRM_DSN') && !empty($GLOBALS['mysql_user'])) {
+ $dbName = !empty($GLOBALS['mysql_db']) ? $GLOBALS['mysql_db'] : 'civicrm_tests_dev';
+ if (empty($GLOBALS['mysql_pass']) && $GLOBALS['mysql_pass_need_password']) {
+ $GLOBALS['mysql_pass'] = PHPUnit_TextUI_Command::getPassword('Password');
}
- define( 'CIVICRM_DSN' , "mysql://{$GLOBALS['mysql_user']}:{$GLOBALS['mysql_pass']}@{$GLOBALS['mysql_host']}/{$dbName}?new_link=true" );
+ define('CIVICRM_DSN', "mysql://{$GLOBALS['mysql_user']}:{$GLOBALS['mysql_pass']}@{$GLOBALS['mysql_host']}/{$dbName}?new_link=true");
}
if (!defined("CIVICRM_DSN")) {
- $dsn= getenv("CIVICRM_TEST_DSN");
+ $dsn = getenv("CIVICRM_TEST_DSN");
if (!empty ($dsn)) {
- define("CIVICRM_DSN",$dsn);
- } else {
+ define("CIVICRM_DSN", $dsn);
+ }
+ else {
echo "\nFATAL: no DB connection configured (CIVICRM_DSN). \nYou can either create/edit " . __DIR__ . "/civicrm.settings.local.php\n";
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
echo "OR set it in your shell:\n \$export CIVICRM_TEST_DSN=mysql://db_username:db_password@localhost/civicrm_tests_dev \n";
- } else {
+ }
+ else {
echo "OR set it in your shell:\n SETX CIVICRM_TEST_DSN mysql://db_username:db_password@localhost/civicrm_tests_dev \n
(you will need to open a new command shell before it takes effect)";
}
-echo "\n\n
+ echo "\n\n
If you haven't done so already, you need to create (once) a database dedicated to the unit tests:
mysql -uroot -p
create database civicrm_tests_dev;
$dsninfo = DB::parseDSN(CIVICRM_DSN);
$GLOBALS['mysql_host'] = $dsninfo['hostspec'];
+$GLOBALS['mysql_port'] = @$dsninfo['port'];
$GLOBALS['mysql_user'] = $dsninfo['username'];
$GLOBALS['mysql_pass'] = $dsninfo['password'];
$GLOBALS['mysql_db'] = $dsninfo['database'];
-
/**
* Content Management System (CMS) Host:
*
* CiviCRM can be hosted in either Drupal, Joomla or WordPress.
-*/
+ */
define('CIVICRM_UF', 'UnitTests');
global $civicrm_root;
if (empty($civicrm_root)) {
- $civicrm_root = dirname (dirname (dirname (dirname( __FILE__ ) )));
+ $civicrm_root = dirname(dirname(dirname(dirname(__FILE__))));
}
#$civicrm_root = '/var/www/drupal7.dev.civicrm.org/public/sites/devel.drupal7.tests.dev.civicrm.org/modules/civicrm';
if (!defined("CIVICRM_TEMPLATE_COMPILEDIR")) {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
- define( 'CIVICRM_TEMPLATE_COMPILEDIR', getenv ('TMP') . DIRECTORY_SEPARATOR . 'civi' . DIRECTORY_SEPARATOR );
- } else {
- define( 'CIVICRM_TEMPLATE_COMPILEDIR', '/tmp/civi/' );
+ define('CIVICRM_TEMPLATE_COMPILEDIR', getenv('TMP') . DIRECTORY_SEPARATOR . 'civi' . DIRECTORY_SEPARATOR);
+ }
+ else {
+ define('CIVICRM_TEMPLATE_COMPILEDIR', '/tmp/civi/');
}
}
-define( 'CIVICRM_SITE_KEY', 'phpunittestfakekey' );
+define('CIVICRM_SITE_KEY', 'phpunittestfakekey');
/**
* Site URLs:
*
*/
if (!defined('CIVICRM_UF_BASEURL')) {
- define( 'CIVICRM_UF_BASEURL' , 'http://FIX ME' );
+ define('CIVICRM_UF_BASEURL', 'http://FIX ME');
}
/**
*
*/
-$include_path = '.' . PATH_SEPARATOR .
- $civicrm_root . PATH_SEPARATOR .
- $civicrm_root . DIRECTORY_SEPARATOR . 'packages' . PATH_SEPARATOR .
- get_include_path( );
-set_include_path( $include_path );
+$include_path = '.' . PATH_SEPARATOR .
+ $civicrm_root . PATH_SEPARATOR .
+ $civicrm_root . DIRECTORY_SEPARATOR . 'packages' . PATH_SEPARATOR .
+ get_include_path();
+set_include_path($include_path);
-if ( function_exists( 'variable_get' ) && variable_get('clean_url', '0') != '0' ) {
- define( 'CIVICRM_CLEANURL', 1 );
-} else {
- define( 'CIVICRM_CLEANURL', 0 );
+if (function_exists('variable_get') && variable_get('clean_url', '0') != '0') {
+ define('CIVICRM_CLEANURL', 1);
+}
+else {
+ define('CIVICRM_CLEANURL', 0);
}
// force PHP to auto-detect Mac line endings
// make sure the memory_limit is at least 64 MB
$memLimitString = trim(ini_get('memory_limit'));
-$memLimitUnit = strtolower(substr($memLimitString, -1));
-$memLimit = (int) $memLimitString;
+$memLimitUnit = strtolower(substr($memLimitString, -1));
+$memLimit = (int) $memLimitString;
switch ($memLimitUnit) {
- case 'g': $memLimit *= 1024;
- case 'm': $memLimit *= 1024;
- case 'k': $memLimit *= 1024;
+ case 'g':
+ $memLimit *= 1024;
+ case 'm':
+ $memLimit *= 1024;
+ case 'k':
+ $memLimit *= 1024;
}
if ($memLimit >= 0 and $memLimit < 67108864) {
- ini_set('memory_limit', '64M');
+ ini_set('memory_limit', '64M');
}
require_once 'CRM/Core/ClassLoader.php';