3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
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
{
43 function __construct() {
44 $this->is_drupal
= FALSE;
45 $this->supports_form_extensions
= False;
49 * sets the title of the page
51 * @param string $title
52 * @param null $pageTitle
54 * @paqram string $pageTitle
60 * @param string $title
61 * @param null $pageTitle
63 function setTitle($title, $pageTitle = NULL) {
68 * Authenticate the user against the drupal db
70 * @param string $name the user name
71 * @param string $password the password for the above user name
72 * @param boolean $loadCMSBootstrap load cms bootstrap?
73 * @param NULL|string $realPath filename of script
75 * @return mixed false if no auth
77 * contactID, ufID, unique string ) if success
82 * @param string $password
83 * @param bool $loadCMSBootstrap
84 * @param null|string $realPath
88 static function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
89 $retVal = array(1, 1, 12345);
94 * Append an additional breadcrumb tag to the existing breadcrumb
98 * @internal param string $title
99 * @internal param string $url
105 * @param $breadCrumbs
107 function appendBreadCrumb($breadCrumbs) {
111 function resetBreadCrumb() {
116 * Append a string to the head of the html file
118 * @param string $header the new string to be appended
124 * @param string $head
126 function addHTMLHead($head) {
130 function mapConfigToSSL() {
132 $base_url = str_replace('http://', 'https://', $base_url);
136 * figure out the post url for the form
138 * @param mix $action the default action if one is pre-specified
140 * @return string the url to post the form
148 function postURL($action) {
153 * Generate an internal CiviCRM URL (copied from DRUPAL/includes/common.inc#url)
155 * @param $path string The path being linked to, such as "civicrm/add"
156 * @param $query string A query string to append to the link.
157 * @param $absolute boolean Whether to force the output to be an absolute link (beginning with http:).
158 * Useful for links that will be displayed outside the site, such as in an
160 * @param $fragment string A fragment identifier (named anchor) to append to the link.
161 * @param $htmlize boolean whether to convert to html eqivalant
162 * @param $frontend boolean a gross joomla hack
163 * @param $forceBackend boolean a gross joomla hack
165 * @return string an HTML string containing a link to the given path.
170 * @param null|string $path
171 * @param null|string $query
172 * @param bool $absolute
173 * @param null|string $fragment
174 * @param bool $htmlize
175 * @param bool $frontend
176 * @param bool $forceBackend
180 function url($path = NULL, $query = NULL, $absolute = FALSE,
181 $fragment = NULL, $htmlize = TRUE,
182 $frontend = FALSE, $forceBackend = FALSE
184 $config = CRM_Core_Config
::singleton();
185 static $script = 'index.php';
187 if (isset($fragment)) {
188 $fragment = '#' . $fragment;
191 if (!isset($config->useFrameworkRelativeBase
)) {
192 $base = parse_url($config->userFrameworkBaseURL
);
193 $config->useFrameworkRelativeBase
= $base['path'];
195 $base = $absolute ?
$config->userFrameworkBaseURL
: $config->useFrameworkRelativeBase
;
197 $separator = $htmlize ?
'&' : '&';
199 if (!$config->cleanURL
) {
202 return $base . $script . '?q=' . $path . $separator . $query . $fragment;
205 return $base . $script . '?q=' . $path . $fragment;
210 return $base . $script . '?' . $query . $fragment;
213 return $base . $fragment;
220 return $base . $path . '?' . $query . $fragment;
223 return $base . $path . $fragment;
228 return $base . $script . '?' . $query . $fragment;
231 return $base . $fragment;
240 function getUserID($user) {
241 //FIXME: look here a bit closer when testing UFMatch
243 // this puts the appropriate values in the session, so
244 // no need to return anything
245 CRM_Core_BAO_UFMatch
::synchronize($user, TRUE, 'Standalone', 'Individual');
253 function getAllowedToLogin($user) {
258 * Set a message in the UF to display to a user
260 * @param string $message the message to set
265 * @param string $message
267 function setMessage($message) {
271 function permissionDenied() {
272 CRM_Core_Error
::fatal(ts('You do not have permission to access this page'));
277 header("Location:index.php");
281 * Get the locale set in the hosting CMS
283 * @return string with the locale or null for none
288 function getUFLocale() {
293 * Get a list of all installed modules, including enabled and disabled ones
295 * @return array CRM_Core_Module
300 function getModules() {
305 * Get user login URL for hosting CMS (method declared in each CMS system class)
307 * @param string $destination - if present, add destination to querystring (works for Drupal only)
310 * @return string - loginURL for the current CMS
313 public function getLoginURL($destination = '') {
314 throw new Exception("Method not implemented: getLoginURL");
318 * Over-ridable function to get timezone as a string eg.
319 * @return string Timezone e.g. 'America/Los_Angeles'
321 function getTimeZoneString() {
322 // This class extends Drupal, but we don't want Drupal's behavior; reproduce CRM_Utils_System_Base::getTimeZoneString
323 return date_default_timezone_get();