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
{
43 public 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
59 * @param string $title
60 * @param null $pageTitle
62 public function setTitle($title, $pageTitle = NULL) {
67 * Authenticate the user against the drupal db
69 * @param string $name the user name
70 * @param string $password the password for the above user name
71 * @param boolean $loadCMSBootstrap load cms bootstrap?
72 * @param NULL|string $realPath filename of script
74 * @return mixed false if no auth
76 * contactID, ufID, unique string ) if success
80 * @param string $password
81 * @param bool $loadCMSBootstrap
82 * @param null|string $realPath
86 public static function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
87 $retVal = array(1, 1, 12345);
92 * Append an additional breadcrumb tag to the existing breadcrumb
96 * @internal param string $title
97 * @internal param string $url
102 * @param $breadCrumbs
104 public function appendBreadCrumb($breadCrumbs) {
108 public function resetBreadCrumb() {
113 * Append a string to the head of the html file
115 * @param string $header the new string to be appended
120 * @param string $head
122 public function addHTMLHead($head) {
126 public function mapConfigToSSL() {
128 $base_url = str_replace('http://', 'https://', $base_url);
132 * Figure out the post url for the form
134 * @param mix $action the default action if one is pre-specified
136 * @return string the url to post the form
143 public function postURL($action) {
148 * Generate an internal CiviCRM URL (copied from DRUPAL/includes/common.inc#url)
150 * @param $path string The path being linked to, such as "civicrm/add"
151 * @param $query string A query string to append to the link.
152 * @param $absolute boolean Whether to force the output to be an absolute link (beginning with http:).
153 * Useful for links that will be displayed outside the site, such as in an
155 * @param $fragment string A fragment identifier (named anchor) to append to the link.
156 * @param $htmlize boolean whether to convert to html eqivalant
157 * @param $frontend boolean a gross joomla hack
158 * @param $forceBackend boolean a gross joomla hack
160 * @return string an HTML string containing a link to the given path.
164 * @param null|string $path
165 * @param null|string $query
166 * @param bool $absolute
167 * @param null|string $fragment
168 * @param bool $htmlize
169 * @param bool $frontend
170 * @param bool $forceBackend
174 function url($path = NULL, $query = NULL, $absolute = FALSE,
175 $fragment = NULL, $htmlize = TRUE,
176 $frontend = FALSE, $forceBackend = FALSE
178 $config = CRM_Core_Config
::singleton();
179 static $script = 'index.php';
181 if (isset($fragment)) {
182 $fragment = '#' . $fragment;
185 if (!isset($config->useFrameworkRelativeBase
)) {
186 $base = parse_url($config->userFrameworkBaseURL
);
187 $config->useFrameworkRelativeBase
= $base['path'];
189 $base = $absolute ?
$config->userFrameworkBaseURL
: $config->useFrameworkRelativeBase
;
191 $separator = $htmlize ?
'&' : '&';
193 if (!$config->cleanURL
) {
196 return $base . $script . '?q=' . $path . $separator . $query . $fragment;
199 return $base . $script . '?q=' . $path . $fragment;
204 return $base . $script . '?' . $query . $fragment;
207 return $base . $fragment;
214 return $base . $path . '?' . $query . $fragment;
217 return $base . $path . $fragment;
222 return $base . $script . '?' . $query . $fragment;
225 return $base . $fragment;
234 public function getUserID($user) {
235 //FIXME: look here a bit closer when testing UFMatch
237 // this puts the appropriate values in the session, so
238 // no need to return anything
239 CRM_Core_BAO_UFMatch
::synchronize($user, TRUE, 'Standalone', 'Individual');
247 public function getAllowedToLogin($user) {
252 * Set a message in the UF to display to a user
254 * @param string $message the message to set
258 * @param string $message
260 public function setMessage($message) {
264 public function permissionDenied() {
265 CRM_Core_Error
::fatal(ts('You do not have permission to access this page.'));
268 public function logout() {
270 header("Location:index.php");
274 * Get the locale set in the hosting CMS
276 * @return string with the locale or null for none
281 public function getUFLocale() {
286 * Get a list of all installed modules, including enabled and disabled ones
288 * @return array CRM_Core_Module
293 public function getModules() {
298 * Get user login URL for hosting CMS (method declared in each CMS system class)
300 * @param string $destination - if present, add destination to querystring (works for Drupal only)
303 * @return string - loginURL for the current CMS
306 public function getLoginURL($destination = '') {
307 throw new Exception("Method not implemented: getLoginURL");
311 * Over-ridable function to get timezone as a string eg.
312 * @return string Timezone e.g. 'America/Los_Angeles'
314 public function getTimeZoneString() {
315 // This class extends Drupal, but we don't want Drupal's behavior; reproduce CRM_Utils_System_Base::getTimeZoneString
316 return date_default_timezone_get();
319 public function clearResourceCache() {
320 // UGH. Obscure Drupal-specific implementation. Why does UnitTests extend Drupal?
321 // You should delete this function if the base-classes are properly rearranged.