Merge pull request #13811 from totten/master-wp-loadboot
[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 {
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.
dc1e9be8 57 */
9ba02e3e 58 public function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) {
dc1e9be8
TO
59 return TRUE;
60 }
61
bb3a214a 62 /**
66e42142 63 * @inheritDoc
bb3a214a 64 */
00be9182 65 public function mapConfigToSSL() {
6a488035
TO
66 global $base_url;
67 $base_url = str_replace('http://', 'https://', $base_url);
68 }
69
bb3a214a 70 /**
66e42142 71 * @inheritDoc
bb3a214a 72 */
00be9182 73 public function postURL($action) {
c301f76e 74 return NULL;
6a488035
TO
75 }
76
bb3a214a 77 /**
66e42142 78 * @inheritDoc
bb3a214a 79 */
c301f76e 80 public function url(
66e42142
CW
81 $path = NULL,
82 $query = NULL,
83 $absolute = FALSE,
84 $fragment = NULL,
85 $htmlize = TRUE,
86 $frontend = FALSE,
87 $forceBackend = FALSE
6a488035
TO
88 ) {
89 $config = CRM_Core_Config::singleton();
90 static $script = 'index.php';
91
92 if (isset($fragment)) {
93 $fragment = '#' . $fragment;
94 }
95
96 if (!isset($config->useFrameworkRelativeBase)) {
97 $base = parse_url($config->userFrameworkBaseURL);
98 $config->useFrameworkRelativeBase = $base['path'];
99 }
100 $base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase;
101
102 $separator = $htmlize ? '&amp;' : '&';
103
104 if (!$config->cleanURL) {
105 if (isset($path)) {
106 if (isset($query)) {
107 return $base . $script . '?q=' . $path . $separator . $query . $fragment;
108 }
109 else {
110 return $base . $script . '?q=' . $path . $fragment;
111 }
112 }
113 else {
114 if (isset($query)) {
115 return $base . $script . '?' . $query . $fragment;
116 }
117 else {
118 return $base . $fragment;
119 }
120 }
121 }
122 else {
123 if (isset($path)) {
124 if (isset($query)) {
125 return $base . $path . '?' . $query . $fragment;
126 }
127 else {
128 return $base . $path . $fragment;
129 }
130 }
131 else {
132 if (isset($query)) {
133 return $base . $script . '?' . $query . $fragment;
134 }
135 else {
136 return $base . $fragment;
137 }
138 }
139 }
140 }
141
bb3a214a
EM
142 /**
143 * @param $user
144 */
00be9182 145 public function getUserID($user) {
6a488035
TO
146 //FIXME: look here a bit closer when testing UFMatch
147
148 // this puts the appropriate values in the session, so
149 // no need to return anything
150 CRM_Core_BAO_UFMatch::synchronize($user, TRUE, 'Standalone', 'Individual');
151 }
152
bb3a214a 153 /**
66e42142 154 * @inheritDoc
bb3a214a 155 */
00be9182 156 public function logout() {
6a488035 157 session_destroy();
d42a224c 158 CRM_Utils_System::setHttpHeader("Location", "index.php");
6a488035
TO
159 }
160
bb3a214a 161 /**
66e42142 162 * @inheritDoc
6a488035
TO
163 */
164 public function getLoginURL($destination = '') {
165 throw new Exception("Method not implemented: getLoginURL");
166 }
450f494d 167
6a488035 168}