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