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