Merge pull request #12201 from seamuslee001/report_activity_117
[civicrm-core.git] / CRM / Utils / System / UnitTests.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
8c9251b3 6 | Copyright CiviCRM LLC (c) 2004-2018 |
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 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
29 *
30 * @package CRM
8c9251b3 31 * @copyright CiviCRM LLC (c) 2004-2018
6a488035
TO
32 * $Id$
33 *
34 */
35
36/**
37 * Helper authentication class for unit tests
38 */
66e42142 39class CRM_Utils_System_UnitTests extends CRM_Utils_System_Base {
bb3a214a 40 /**
bb3a214a 41 */
00be9182 42 public function __construct() {
6a488035 43 $this->is_drupal = FALSE;
e7292422 44 $this->supports_form_extensions = FALSE;
6a488035
TO
45 }
46
bb3a214a 47 /**
66e42142 48 * @inheritDoc
bb3a214a 49 */
17f443df 50 public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
6a488035
TO
51 $retVal = array(1, 1, 12345);
52 return $retVal;
53 }
54
dc1e9be8
TO
55 /**
56 * Bootstrap the phony CMS.
57 *
58 * @param string $name
59 * Optional username for login.
60 * @param string $pass
61 * Optional password for login.
62 *
63 * @return bool
64 */
65 public function loadBootStrap($name = NULL, $pass = NULL) {
66 return TRUE;
67 }
68
bb3a214a 69 /**
66e42142 70 * @inheritDoc
bb3a214a 71 */
00be9182 72 public function mapConfigToSSL() {
6a488035
TO
73 global $base_url;
74 $base_url = str_replace('http://', 'https://', $base_url);
75 }
76
bb3a214a 77 /**
66e42142 78 * @inheritDoc
bb3a214a 79 */
00be9182 80 public function postURL($action) {
c301f76e 81 return NULL;
6a488035
TO
82 }
83
bb3a214a 84 /**
66e42142 85 * @inheritDoc
bb3a214a 86 */
c301f76e 87 public function url(
66e42142
CW
88 $path = NULL,
89 $query = NULL,
90 $absolute = FALSE,
91 $fragment = NULL,
92 $htmlize = TRUE,
93 $frontend = FALSE,
94 $forceBackend = FALSE
6a488035
TO
95 ) {
96 $config = CRM_Core_Config::singleton();
97 static $script = 'index.php';
98
99 if (isset($fragment)) {
100 $fragment = '#' . $fragment;
101 }
102
103 if (!isset($config->useFrameworkRelativeBase)) {
104 $base = parse_url($config->userFrameworkBaseURL);
105 $config->useFrameworkRelativeBase = $base['path'];
106 }
107 $base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase;
108
109 $separator = $htmlize ? '&amp;' : '&';
110
111 if (!$config->cleanURL) {
112 if (isset($path)) {
113 if (isset($query)) {
114 return $base . $script . '?q=' . $path . $separator . $query . $fragment;
115 }
116 else {
117 return $base . $script . '?q=' . $path . $fragment;
118 }
119 }
120 else {
121 if (isset($query)) {
122 return $base . $script . '?' . $query . $fragment;
123 }
124 else {
125 return $base . $fragment;
126 }
127 }
128 }
129 else {
130 if (isset($path)) {
131 if (isset($query)) {
132 return $base . $path . '?' . $query . $fragment;
133 }
134 else {
135 return $base . $path . $fragment;
136 }
137 }
138 else {
139 if (isset($query)) {
140 return $base . $script . '?' . $query . $fragment;
141 }
142 else {
143 return $base . $fragment;
144 }
145 }
146 }
147 }
148
bb3a214a
EM
149 /**
150 * @param $user
151 */
00be9182 152 public function getUserID($user) {
6a488035
TO
153 //FIXME: look here a bit closer when testing UFMatch
154
155 // this puts the appropriate values in the session, so
156 // no need to return anything
157 CRM_Core_BAO_UFMatch::synchronize($user, TRUE, 'Standalone', 'Individual');
158 }
159
bb3a214a 160 /**
66e42142 161 * @inheritDoc
bb3a214a 162 */
00be9182 163 public function logout() {
6a488035 164 session_destroy();
d42a224c 165 CRM_Utils_System::setHttpHeader("Location", "index.php");
6a488035
TO
166 }
167
bb3a214a 168 /**
66e42142 169 * @inheritDoc
6a488035
TO
170 */
171 public function getLoginURL($destination = '') {
172 throw new Exception("Method not implemented: getLoginURL");
173 }
450f494d 174
6a488035 175}