3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * Helper authentication class for unit tests
39 class CRM_Utils_System_UnitTests
extends CRM_Utils_System_Drupal
{
42 public function __construct() {
43 $this->is_drupal
= FALSE;
44 $this->supports_form_extensions
= FALSE;
48 * Sets the title of the page
50 * @param string $title
51 * @param null $pageTitle
53 * @paqram string $pageTitle
58 * @param string $title
59 * @param null $pageTitle
61 public function setTitle($title, $pageTitle = NULL) {
66 * Authenticate the user against the drupal db
70 * @param string $password
71 * The password for the above user name.
72 * @param bool $loadCMSBootstrap
73 * Load cms bootstrap?.
74 * @param NULL|string $realPath filename of script
77 * [contactID, ufID, uniqueString] if success else false if no auth
81 * @param string $password
82 * @param bool $loadCMSBootstrap
83 * @param null|string $realPath
87 public static function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
88 $retVal = array(1, 1, 12345);
93 * Append an additional breadcrumb tag to the existing breadcrumb
97 * @internal param string $title
98 * @internal param string $url
103 * @param $breadCrumbs
105 public function appendBreadCrumb($breadCrumbs) {
109 public function resetBreadCrumb() {
114 * Append a string to the head of the html file
116 * @param string $header
117 * The new string to be appended.
122 * @param string $head
124 public function addHTMLHead($head) {
128 public function mapConfigToSSL() {
130 $base_url = str_replace('http://', 'https://', $base_url);
134 * Figure out the post url for the form
137 * The default action if one is pre-specified.
140 * the url to post the form
147 public function postURL($action) {
152 * Generate an internal CiviCRM URL (copied from DRUPAL/includes/common.inc#url)
154 * @param string $path
155 * The path being linked to, such as "civicrm/add".
156 * @param string $query
157 * A query string to append to the link.
158 * @param bool $absolute
159 * Whether to force the output to be an absolute link (beginning with http:).
160 * Useful for links that will be displayed outside the site, such as in an
162 * @param string $fragment
163 * A fragment identifier (named anchor) to append to the link.
164 * @param bool $htmlize
165 * whether to convert to html eqivalant.
166 * @param bool $frontend
167 * a gross joomla hack.
168 * @param bool $forceBackend
169 * a gross joomla hack.
172 * an HTML string containing a link to the given path.
175 * @param null|string $path
176 * @param null|string $query
177 * @param bool $absolute
178 * @param null|string $fragment
179 * @param bool $htmlize
180 * @param bool $frontend
181 * @param bool $forceBackend
186 $path = NULL, $query = NULL, $absolute = FALSE,
187 $fragment = NULL, $htmlize = TRUE,
188 $frontend = FALSE, $forceBackend = FALSE
190 $config = CRM_Core_Config
::singleton();
191 static $script = 'index.php';
193 if (isset($fragment)) {
194 $fragment = '#' . $fragment;
197 if (!isset($config->useFrameworkRelativeBase
)) {
198 $base = parse_url($config->userFrameworkBaseURL
);
199 $config->useFrameworkRelativeBase
= $base['path'];
201 $base = $absolute ?
$config->userFrameworkBaseURL
: $config->useFrameworkRelativeBase
;
203 $separator = $htmlize ?
'&' : '&';
205 if (!$config->cleanURL
) {
208 return $base . $script . '?q=' . $path . $separator . $query . $fragment;
211 return $base . $script . '?q=' . $path . $fragment;
216 return $base . $script . '?' . $query . $fragment;
219 return $base . $fragment;
226 return $base . $path . '?' . $query . $fragment;
229 return $base . $path . $fragment;
234 return $base . $script . '?' . $query . $fragment;
237 return $base . $fragment;
246 public function getUserID($user) {
247 //FIXME: look here a bit closer when testing UFMatch
249 // this puts the appropriate values in the session, so
250 // no need to return anything
251 CRM_Core_BAO_UFMatch
::synchronize($user, TRUE, 'Standalone', 'Individual');
259 public function getAllowedToLogin($user) {
264 * Set a message in the UF to display to a user
266 * @param string $message
267 * The message to set.
270 * @param string $message
272 public function setMessage($message) {
276 public function permissionDenied() {
277 CRM_Core_Error
::fatal(ts('You do not have permission to access this page.'));
280 public function logout() {
282 header("Location:index.php");
286 * Get the locale set in the hosting CMS
289 * with the locale or null for none
294 public function getUFLocale() {
299 * Get a list of all installed modules, including enabled and disabled ones
307 public function getModules() {
312 * Get user login URL for hosting CMS (method declared in each CMS system class)
314 * @param string $destination
315 * If present, add destination to querystring (works for Drupal only).
318 * loginURL for the current CMS
320 public function getLoginURL($destination = '') {
321 throw new Exception("Method not implemented: getLoginURL");
325 * Over-ridable function to get timezone as a string eg.
327 * Timezone e.g. 'America/Los_Angeles'
329 public function getTimeZoneString() {
330 // This class extends Drupal, but we don't want Drupal's behavior; reproduce CRM_Utils_System_Base::getTimeZoneString
331 return date_default_timezone_get();
334 public function clearResourceCache() {
335 // UGH. Obscure Drupal-specific implementation. Why does UnitTests extend Drupal?
336 // You should delete this function if the base-classes are properly rearranged.