Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06b69b18 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * Helper authentication class for unit tests | |
38 | */ | |
39 | class CRM_Utils_System_UnitTests extends CRM_Utils_System_Drupal { | |
40 | function __construct() { | |
41 | $this->is_drupal = FALSE; | |
42 | $this->supports_form_extensions = False; | |
43 | } | |
44 | ||
45 | function setTitle($title, $pageTitle = NULL) { | |
46 | return; | |
47 | } | |
48 | ||
49 | static function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) { | |
50 | $retVal = array(1, 1, 12345); | |
51 | return $retVal; | |
52 | } | |
53 | ||
54 | function appendBreadCrumb($breadCrumbs) { | |
55 | return; | |
56 | } | |
57 | ||
58 | function resetBreadCrumb() { | |
59 | return; | |
60 | } | |
61 | ||
62 | function addHTMLHead($head) { | |
63 | return; | |
64 | } | |
65 | ||
66 | function mapConfigToSSL() { | |
67 | global $base_url; | |
68 | $base_url = str_replace('http://', 'https://', $base_url); | |
69 | } | |
70 | ||
71 | function postURL($action) { | |
72 | return; | |
73 | } | |
74 | ||
75 | function url($path = NULL, $query = NULL, $absolute = FALSE, | |
76 | $fragment = NULL, $htmlize = TRUE, | |
77 | $frontend = FALSE, $forceBackend = FALSE | |
78 | ) { | |
79 | $config = CRM_Core_Config::singleton(); | |
80 | static $script = 'index.php'; | |
81 | ||
82 | if (isset($fragment)) { | |
83 | $fragment = '#' . $fragment; | |
84 | } | |
85 | ||
86 | if (!isset($config->useFrameworkRelativeBase)) { | |
87 | $base = parse_url($config->userFrameworkBaseURL); | |
88 | $config->useFrameworkRelativeBase = $base['path']; | |
89 | } | |
90 | $base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase; | |
91 | ||
92 | $separator = $htmlize ? '&' : '&'; | |
93 | ||
94 | if (!$config->cleanURL) { | |
95 | if (isset($path)) { | |
96 | if (isset($query)) { | |
97 | return $base . $script . '?q=' . $path . $separator . $query . $fragment; | |
98 | } | |
99 | else { | |
100 | return $base . $script . '?q=' . $path . $fragment; | |
101 | } | |
102 | } | |
103 | else { | |
104 | if (isset($query)) { | |
105 | return $base . $script . '?' . $query . $fragment; | |
106 | } | |
107 | else { | |
108 | return $base . $fragment; | |
109 | } | |
110 | } | |
111 | } | |
112 | else { | |
113 | if (isset($path)) { | |
114 | if (isset($query)) { | |
115 | return $base . $path . '?' . $query . $fragment; | |
116 | } | |
117 | else { | |
118 | return $base . $path . $fragment; | |
119 | } | |
120 | } | |
121 | else { | |
122 | if (isset($query)) { | |
123 | return $base . $script . '?' . $query . $fragment; | |
124 | } | |
125 | else { | |
126 | return $base . $fragment; | |
127 | } | |
128 | } | |
129 | } | |
130 | } | |
131 | ||
132 | function getUserID($user) { | |
133 | //FIXME: look here a bit closer when testing UFMatch | |
134 | ||
135 | // this puts the appropriate values in the session, so | |
136 | // no need to return anything | |
137 | CRM_Core_BAO_UFMatch::synchronize($user, TRUE, 'Standalone', 'Individual'); | |
138 | } | |
139 | ||
140 | function getAllowedToLogin($user) { | |
141 | return TRUE; | |
142 | } | |
143 | ||
144 | function setMessage($message) { | |
145 | return; | |
146 | } | |
147 | ||
148 | function permissionDenied() { | |
149 | CRM_Core_Error::fatal(ts('You do not have permission to access this page')); | |
150 | } | |
151 | ||
152 | function logout() { | |
153 | session_destroy(); | |
154 | header("Location:index.php"); | |
155 | } | |
156 | ||
157 | function getUFLocale() { | |
158 | return NULL; | |
159 | } | |
160 | ||
161 | function getModules() { | |
162 | return array(); | |
163 | } | |
164 | ||
165 | /** | |
166 | * Get user login URL for hosting CMS (method declared in each CMS system class) | |
167 | * | |
168 | * @param string $destination - if present, add destination to querystring (works for Drupal only) | |
169 | * | |
170 | * @return string - loginURL for the current CMS | |
171 | * @static | |
172 | */ | |
173 | public function getLoginURL($destination = '') { | |
174 | throw new Exception("Method not implemented: getLoginURL"); | |
175 | } | |
450f494d | 176 | |
48ec57ab TO |
177 | /** |
178 | * Over-ridable function to get timezone as a string eg. | |
179 | * @return string Timezone e.g. 'America/Los_Angeles' | |
180 | */ | |
181 | function getTimeZoneString() { | |
182 | // This class extends Drupal, but we don't want Drupal's behavior; reproduce CRM_Utils_System_Base::getTimeZoneString | |
183 | return date_default_timezone_get(); | |
184 | } | |
6a488035 TO |
185 | } |
186 |