Merge pull request #7629 from colemanw/CRM-17645
[civicrm-core.git] / tests / phpunit / CiviTest / civicrm.settings.dist.php
CommitLineData
6a488035
TO
1<?php
2
4897b97b 3define('CIVICRM_TEST', 1);
40787e18 4define('CIVICRM_CONTAINER_CACHE', 'auto');
4897b97b 5
6a488035
TO
6// This file is loaded on all systems running tests. To override settings on
7// your local system, please create "civicrm.settings.local.php" and put
8// the settings there.
9
10//--- 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 ----------
11
92915c55
TO
12if (!defined('CIVICRM_DSN') && !empty($GLOBALS['mysql_user'])) {
13 $dbName = !empty($GLOBALS['mysql_db']) ? $GLOBALS['mysql_db'] : 'civicrm_tests_dev';
481a74f4
TO
14 if (empty($GLOBALS['mysql_pass']) && $GLOBALS['mysql_pass_need_password']) {
15 $GLOBALS['mysql_pass'] = PHPUnit_TextUI_Command::getPassword('Password');
9e1431f7 16 }
481a74f4 17 define('CIVICRM_DSN', "mysql://{$GLOBALS['mysql_user']}:{$GLOBALS['mysql_pass']}@{$GLOBALS['mysql_host']}/{$dbName}?new_link=true");
6a488035
TO
18}
19
20
21if (!defined("CIVICRM_DSN")) {
6c6e6187 22 $dsn = getenv("CIVICRM_TEST_DSN");
6a488035 23 if (!empty ($dsn)) {
6c6e6187 24 define("CIVICRM_DSN", $dsn);
0db6c3e1
TO
25 }
26 else {
6a488035
TO
27 echo "\nFATAL: no DB connection configured (CIVICRM_DSN). \nYou can either create/edit " . __DIR__ . "/civicrm.settings.local.php\n";
28 if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
29 echo "OR set it in your shell:\n \$export CIVICRM_TEST_DSN=mysql://db_username:db_password@localhost/civicrm_tests_dev \n";
0db6c3e1
TO
30 }
31 else {
6a488035
TO
32 echo "OR set it in your shell:\n SETX CIVICRM_TEST_DSN mysql://db_username:db_password@localhost/civicrm_tests_dev \n
33 (you will need to open a new command shell before it takes effect)";
34 }
6c6e6187 35 echo "\n\n
6a488035
TO
36If you haven't done so already, you need to create (once) a database dedicated to the unit tests:
37mysql -uroot -p
38create database civicrm_tests_dev;
39grant ALL on civicrm_tests_dev.* to db_username@localhost identified by 'db_password';
40grant SUPER on *.* to db_username@localhost identified by 'db_password';\n";
41 die ("");
42 }
43}
44
45
46require_once "DB.php";
47$dsninfo = DB::parseDSN(CIVICRM_DSN);
48
49$GLOBALS['mysql_host'] = $dsninfo['hostspec'];
fc3c781d 50$GLOBALS['mysql_port'] = @$dsninfo['port'];
6a488035
TO
51$GLOBALS['mysql_user'] = $dsninfo['username'];
52$GLOBALS['mysql_pass'] = $dsninfo['password'];
53$GLOBALS['mysql_db'] = $dsninfo['database'];
54
6a488035
TO
55/**
56 * Content Management System (CMS) Host:
57 *
58 * CiviCRM can be hosted in either Drupal, Joomla or WordPress.
92915c55 59 */
6a488035
TO
60define('CIVICRM_UF', 'UnitTests');
61
62
63global $civicrm_root;
64if (empty($civicrm_root)) {
481a74f4 65 $civicrm_root = dirname(dirname(dirname(dirname(__FILE__))));
6a488035 66}
97d5a31f 67#$civicrm_root = '/var/www/drupal7.dev.civicrm.org/public/sites/devel.drupal7.tests.dev.civicrm.org/modules/civicrm';
6a488035
TO
68
69// set this to a temporary directory. it defaults to /tmp/civi on linux
70//define( 'CIVICRM_TEMPLATE_COMPILEDIR', 'the/absolute/path/' );
71
72if (!defined("CIVICRM_TEMPLATE_COMPILEDIR")) {
73 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
481a74f4 74 define('CIVICRM_TEMPLATE_COMPILEDIR', getenv('TMP') . DIRECTORY_SEPARATOR . 'civi' . DIRECTORY_SEPARATOR);
0db6c3e1
TO
75 }
76 else {
481a74f4 77 define('CIVICRM_TEMPLATE_COMPILEDIR', '/tmp/civi/');
6a488035
TO
78 }
79}
80
481a74f4 81define('CIVICRM_SITE_KEY', 'phpunittestfakekey');
6a488035
TO
82
83/**
84 * Site URLs:
85 *
86 * This section defines absolute and relative URLs to access the host CMS (Drupal or Joomla) resources.
87 *
88 * IMPORTANT: Trailing slashes should be used on all URL settings.
89 *
90 *
91 * EXAMPLE - Drupal Installations:
92 * If your site's home url is http://www.example.com/drupal/
93 * these variables would be set as below. Modify as needed for your install.
94 *
95 * CIVICRM_UF_BASEURL - home URL for your site:
96 * define( 'CIVICRM_UF_BASEURL' , 'http://www.example.com/drupal/' );
97 *
98 * EXAMPLE - Joomla Installations:
99 * If your site's home url is http://www.example.com/joomla/
100 *
101 * CIVICRM_UF_BASEURL - home URL for your site:
102 * Administration site:
103 * define( 'CIVICRM_UF_BASEURL' , 'http://www.example.com/joomla/administrator/' );
104 * Front-end site:
105 * define( 'CIVICRM_UF_BASEURL' , 'http://www.example.com/joomla/' );
106 *
107 */
108if (!defined('CIVICRM_UF_BASEURL')) {
481a74f4 109 define('CIVICRM_UF_BASEURL', 'http://FIX ME');
6a488035
TO
110}
111
112/**
113 * Configure MySQL to throw more errors when encountering unusual SQL expressions.
114 *
115 * If undefined, the value is determined automatically. For CiviCRM tarballs, it defaults
116 * to FALSE; for SVN checkouts, it defaults to TRUE.
117 */
118define('CIVICRM_MYSQL_STRICT', TRUE);
119
120/**
121 *
122 * Do not change anything below this line. Keep as is
123 *
124 */
125
92915c55
TO
126$include_path = '.' . PATH_SEPARATOR .
127 $civicrm_root . PATH_SEPARATOR .
128 $civicrm_root . DIRECTORY_SEPARATOR . 'packages' . PATH_SEPARATOR .
129 get_include_path();
481a74f4 130set_include_path($include_path);
6a488035 131
481a74f4
TO
132if (function_exists('variable_get') && variable_get('clean_url', '0') != '0') {
133 define('CIVICRM_CLEANURL', 1);
2241036a
TO
134}
135else {
481a74f4 136 define('CIVICRM_CLEANURL', 0);
6a488035
TO
137}
138
139// force PHP to auto-detect Mac line endings
140ini_set('auto_detect_line_endings', '1');
141
142// make sure the memory_limit is at least 64 MB
143$memLimitString = trim(ini_get('memory_limit'));
92915c55
TO
144$memLimitUnit = strtolower(substr($memLimitString, -1));
145$memLimit = (int) $memLimitString;
6a488035 146switch ($memLimitUnit) {
92915c55
TO
147 case 'g':
148 $memLimit *= 1024;
149 case 'm':
150 $memLimit *= 1024;
151 case 'k':
152 $memLimit *= 1024;
6a488035
TO
153}
154if ($memLimit >= 0 and $memLimit < 67108864) {
6c6e6187 155 ini_set('memory_limit', '64M');
6a488035
TO
156}
157
158require_once 'CRM/Core/ClassLoader.php';
159CRM_Core_ClassLoader::singleton()->register();