Merge pull request #13971 from eileenmcnaughton/array_format_4
[civicrm-core.git] / CRM / Utils / System / UnitTests.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2019
32 * $Id$
33 *
34 */
35
36 /**
37 * Helper authentication class for unit tests
38 */
39 class CRM_Utils_System_UnitTests extends CRM_Utils_System_Base {
40 /**
41 */
42 public function __construct() {
43 $this->is_drupal = FALSE;
44 $this->supports_form_extensions = FALSE;
45 }
46
47 /**
48 * @inheritDoc
49 */
50 public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
51 $retVal = [1, 1, 12345];
52 return $retVal;
53 }
54
55 /**
56 * Bootstrap the phony CMS.
57 */
58 public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) {
59 return TRUE;
60 }
61
62 /**
63 * @inheritDoc
64 */
65 public function mapConfigToSSL() {
66 global $base_url;
67 $base_url = str_replace('http://', 'https://', $base_url);
68 }
69
70 /**
71 * @inheritDoc
72 */
73 public function postURL($action) {
74 return NULL;
75 }
76
77 /**
78 * @inheritDoc
79 */
80 public function url(
81 $path = NULL,
82 $query = NULL,
83 $absolute = FALSE,
84 $fragment = NULL,
85 $htmlize = TRUE,
86 $frontend = FALSE,
87 $forceBackend = FALSE
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
142 /**
143 * @param $user
144 */
145 public function getUserID($user) {
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
153 /**
154 * @inheritDoc
155 */
156 public function logout() {
157 session_destroy();
158 CRM_Utils_System::setHttpHeader("Location", "index.php");
159 }
160
161 /**
162 * @inheritDoc
163 */
164 public function getLoginURL($destination = '') {
165 throw new Exception("Method not implemented: getLoginURL");
166 }
167
168 }