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