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