Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | * $Id$ |
17 | * | |
18 | */ | |
19 | ||
20 | /** | |
21 | * Helper authentication class for unit tests | |
22 | */ | |
66e42142 | 23 | class CRM_Utils_System_UnitTests extends CRM_Utils_System_Base { |
6714d8d2 | 24 | |
bb3a214a | 25 | /** |
bb3a214a | 26 | */ |
00be9182 | 27 | public function __construct() { |
6a488035 | 28 | $this->is_drupal = FALSE; |
e7292422 | 29 | $this->supports_form_extensions = FALSE; |
6a488035 TO |
30 | } |
31 | ||
103ae50e | 32 | /** |
33 | * @param string $name | |
34 | * @param string $value | |
35 | */ | |
36 | public function setHttpHeader($name, $value) { | |
37 | Civi::$statics[__CLASS__]['header'][] = ("$name: $value"); | |
38 | } | |
39 | ||
bb3a214a | 40 | /** |
66e42142 | 41 | * @inheritDoc |
bb3a214a | 42 | */ |
17f443df | 43 | public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) { |
be2fb01f | 44 | $retVal = [1, 1, 12345]; |
6a488035 TO |
45 | return $retVal; |
46 | } | |
47 | ||
dc1e9be8 TO |
48 | /** |
49 | * Bootstrap the phony CMS. | |
dc1e9be8 | 50 | */ |
be2fb01f | 51 | public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) { |
dc1e9be8 TO |
52 | return TRUE; |
53 | } | |
54 | ||
bb3a214a | 55 | /** |
66e42142 | 56 | * @inheritDoc |
bb3a214a | 57 | */ |
00be9182 | 58 | public function mapConfigToSSL() { |
6a488035 TO |
59 | global $base_url; |
60 | $base_url = str_replace('http://', 'https://', $base_url); | |
61 | } | |
62 | ||
bb3a214a | 63 | /** |
66e42142 | 64 | * @inheritDoc |
bb3a214a | 65 | */ |
00be9182 | 66 | public function postURL($action) { |
c301f76e | 67 | return NULL; |
6a488035 TO |
68 | } |
69 | ||
bb3a214a | 70 | /** |
66e42142 | 71 | * @inheritDoc |
bb3a214a | 72 | */ |
c301f76e | 73 | public function url( |
66e42142 CW |
74 | $path = NULL, |
75 | $query = NULL, | |
76 | $absolute = FALSE, | |
77 | $fragment = NULL, | |
78 | $htmlize = TRUE, | |
79 | $frontend = FALSE, | |
80 | $forceBackend = FALSE | |
6a488035 TO |
81 | ) { |
82 | $config = CRM_Core_Config::singleton(); | |
83 | static $script = 'index.php'; | |
84 | ||
85 | if (isset($fragment)) { | |
86 | $fragment = '#' . $fragment; | |
87 | } | |
88 | ||
89 | if (!isset($config->useFrameworkRelativeBase)) { | |
90 | $base = parse_url($config->userFrameworkBaseURL); | |
91 | $config->useFrameworkRelativeBase = $base['path']; | |
92 | } | |
93 | $base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase; | |
94 | ||
95 | $separator = $htmlize ? '&' : '&'; | |
96 | ||
97 | if (!$config->cleanURL) { | |
98 | if (isset($path)) { | |
99 | if (isset($query)) { | |
100 | return $base . $script . '?q=' . $path . $separator . $query . $fragment; | |
101 | } | |
102 | else { | |
103 | return $base . $script . '?q=' . $path . $fragment; | |
104 | } | |
105 | } | |
106 | else { | |
107 | if (isset($query)) { | |
108 | return $base . $script . '?' . $query . $fragment; | |
109 | } | |
110 | else { | |
111 | return $base . $fragment; | |
112 | } | |
113 | } | |
114 | } | |
115 | else { | |
116 | if (isset($path)) { | |
117 | if (isset($query)) { | |
118 | return $base . $path . '?' . $query . $fragment; | |
119 | } | |
120 | else { | |
121 | return $base . $path . $fragment; | |
122 | } | |
123 | } | |
124 | else { | |
125 | if (isset($query)) { | |
126 | return $base . $script . '?' . $query . $fragment; | |
127 | } | |
128 | else { | |
129 | return $base . $fragment; | |
130 | } | |
131 | } | |
132 | } | |
133 | } | |
134 | ||
bb3a214a EM |
135 | /** |
136 | * @param $user | |
137 | */ | |
00be9182 | 138 | public function getUserID($user) { |
6a488035 TO |
139 | //FIXME: look here a bit closer when testing UFMatch |
140 | ||
141 | // this puts the appropriate values in the session, so | |
142 | // no need to return anything | |
143 | CRM_Core_BAO_UFMatch::synchronize($user, TRUE, 'Standalone', 'Individual'); | |
144 | } | |
145 | ||
bb3a214a | 146 | /** |
66e42142 | 147 | * @inheritDoc |
bb3a214a | 148 | */ |
00be9182 | 149 | public function logout() { |
6a488035 | 150 | session_destroy(); |
d42a224c | 151 | CRM_Utils_System::setHttpHeader("Location", "index.php"); |
6a488035 TO |
152 | } |
153 | ||
bb3a214a | 154 | /** |
66e42142 | 155 | * @inheritDoc |
6a488035 TO |
156 | */ |
157 | public function getLoginURL($destination = '') { | |
158 | throw new Exception("Method not implemented: getLoginURL"); | |
159 | } | |
450f494d | 160 | |
6a488035 | 161 | } |