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