Completed
Push — master ( fcd2f5...01f393 )
by Kenji
12s
created

application/tests/Bootstrap.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 59 and the first side effect is on line 70.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * CodeIgniter
4
 *
5
 * An open source application development framework for PHP
6
 *
7
 * This content is released under the MIT License (MIT)
8
 *
9
 * Copyright (c) 2014 - 2017, British Columbia Institute of Technology
10
 *
11
 * Permission is hereby granted, free of charge, to any person obtaining a copy
12
 * of this software and associated documentation files (the "Software"), to deal
13
 * in the Software without restriction, including without limitation the rights
14
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
 * copies of the Software, and to permit persons to whom the Software is
16
 * furnished to do so, subject to the following conditions:
17
 *
18
 * The above copyright notice and this permission notice shall be included in
19
 * all copies or substantial portions of the Software.
20
 *
21
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
 * THE SOFTWARE.
28
 *
29
 * @package	CodeIgniter
30
 * @author	EllisLab Dev Team
31
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
 * @copyright	Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
33
 * @license	http://opensource.org/licenses/MIT	MIT License
34
 * @link	https://codeigniter.com
35
 * @since	Version 1.0.0
36
 * @filesource
37
 */
38
39
/*
40
 *---------------------------------------------------------------
41
 * APPLICATION ENVIRONMENT
42
 *---------------------------------------------------------------
43
 *
44
 * You can load different configurations depending on your
45
 * current environment. Setting the environment also influences
46
 * things like logging and error reporting.
47
 *
48
 * This can be set to anything, but default usage is:
49
 *
50
 *     development
51
 *     testing
52
 *     production
53
 *
54
 * NOTE: If you change these, also change the error_reporting() code below
55
 */
56
// This `if` statemant is needed for @runInSeparateProcess
57
if (! defined('ENVIRONMENT'))
58
{
59
	define('ENVIRONMENT', 'testing');
60
}
61
62
/*
63
 *---------------------------------------------------------------
64
 * ERROR REPORTING
65
 *---------------------------------------------------------------
66
 *
67
 * Different environments will require different levels of error reporting.
68
 * By default development will show errors but testing and live will hide them.
69
 */
70
switch (ENVIRONMENT)
71
{
72
	case 'testing':
73
	case 'development':
74
		error_reporting(-1);
75
		ini_set('display_errors', 1);
76
	break;
77
78
	case 'production':
79
		ini_set('display_errors', 0);
80
		if (version_compare(PHP_VERSION, '5.3', '>='))
81
		{
82
			error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
83
		}
84
		else
85
		{
86
			error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
87
		}
88
	break;
89
90
	default:
91
		header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
92
		echo 'The application environment is not set correctly.';
93
		exit(1); // EXIT_ERROR
94
}
95
96
/*
97
 *---------------------------------------------------------------
98
 * SYSTEM DIRECTORY NAME
99
 *---------------------------------------------------------------
100
 *
101
 * This variable must contain the name of your "system" directory.
102
 * Set the path if it is not in the same directory as this file.
103
 */
104
	$system_path = '../../system';
105
106
/*
107
 *---------------------------------------------------------------
108
 * APPLICATION DIRECTORY NAME
109
 *---------------------------------------------------------------
110
 *
111
 * If you want this front controller to use a different "application"
112
 * directory than the default one you can set its name here. The directory
113
 * can also be renamed or relocated anywhere on your server. If you do,
114
 * use an absolute (full) server path.
115
 * For more info please see the user guide:
116
 *
117
 * https://codeigniter.com/user_guide/general/managing_apps.html
118
 *
119
 * NO TRAILING SLASH!
120
 */
121
	$application_folder = '../../application';
122
123
/*
124
 *---------------------------------------------------------------
125
 * VIEW DIRECTORY NAME
126
 *---------------------------------------------------------------
127
 *
128
 * If you want to move the view directory out of the application
129
 * directory, set the path to it here. The directory can be renamed
130
 * and relocated anywhere on your server. If blank, it will default
131
 * to the standard location inside your application directory.
132
 * If you do move this, use an absolute (full) server path.
133
 *
134
 * NO TRAILING SLASH!
135
 */
136
	$view_folder = '';
137
138
139
/*
140
 * --------------------------------------------------------------------
141
 * DEFAULT CONTROLLER
142
 * --------------------------------------------------------------------
143
 *
144
 * Normally you will set your default controller in the routes.php file.
145
 * You can, however, force a custom routing by hard-coding a
146
 * specific controller class/function here. For most applications, you
147
 * WILL NOT set your routing here, but it's an option for those
148
 * special instances where you might want to override the standard
149
 * routing in a specific front controller that shares a common CI installation.
150
 *
151
 * IMPORTANT: If you set the routing here, NO OTHER controller will be
152
 * callable. In essence, this preference limits your application to ONE
153
 * specific controller. Leave the function name blank if you need
154
 * to call functions dynamically via the URI.
155
 *
156
 * Un-comment the $routing array below to use this feature
157
 */
158
	// The directory name, relative to the "controllers" directory.  Leave blank
159
	// if your controller is not in a sub-directory within the "controllers" one
160
	// $routing['directory'] = '';
161
162
	// The controller class file name.  Example:  mycontroller
163
	// $routing['controller'] = '';
164
165
	// The controller function you wish to be called.
166
	// $routing['function']	= '';
167
168
169
/*
170
 * -------------------------------------------------------------------
171
 *  CUSTOM CONFIG VALUES
172
 * -------------------------------------------------------------------
173
 *
174
 * The $assign_to_config array below will be passed dynamically to the
175
 * config class when initialized. This allows you to set custom config
176
 * items or override any default config values found in the config.php file.
177
 * This can be handy as it permits you to share one application between
178
 * multiple front controller files, with each file containing different
179
 * config values.
180
 *
181
 * Un-comment the $assign_to_config array below to use this feature
182
 */
183
	// $assign_to_config['name_of_config_item'] = 'value of config item';
184
185
186
187
// --------------------------------------------------------------------
188
// END OF USER CONFIGURABLE SETTINGS.  DO NOT EDIT BELOW THIS LINE
189
// --------------------------------------------------------------------
190
191
/*
192
 * ---------------------------------------------------------------
193
 *  Resolve the system path for increased reliability
194
 * ---------------------------------------------------------------
195
 */
196
197
	// Set the current directory correctly for CLI requests
198
//	if (defined('STDIN'))
199
//	{
200
		// This is needed for @runInSeparateProcess
201
		chdir(dirname(__FILE__));
202
//	}
203
204
	if (($_temp = realpath($system_path)) !== FALSE)
205
	{
206
		$system_path = $_temp.DIRECTORY_SEPARATOR;
207
	}
208
	else
209
	{
210
		// Ensure there's a trailing slash
211
		$system_path = strtr(
212
			rtrim($system_path, '/\\'),
213
			'/\\',
214
			DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
215
		).DIRECTORY_SEPARATOR;
216
217
	}
218
219
	// Is the system path correct?
220
	if ( ! is_dir($system_path))
221
	{
222
		header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
223
		echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME);
224
		exit(3); // EXIT_CONFIG
225
	}
226
227
/*
228
 * -------------------------------------------------------------------
229
 *  Now that we know the path, set the main path constants
230
 * -------------------------------------------------------------------
231
 */
232
	// The name of THIS file
233
	define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
234
235
	// Path to the system directory
236
	define('BASEPATH', $system_path);
237
238
	// Path to the front controller (this file) directory
239
	define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);
240
241
	// Name of the "system" directory
242
	define('SYSDIR', basename(BASEPATH));
243
244
	// The path to the "application" directory
245
	if (is_dir($application_folder))
246
	{
247 View Code Duplication
		if (($_temp = realpath($application_folder)) !== FALSE)
248
		{
249
			$application_folder = $_temp;
250
		}
251
		else
252
		{
253
			$application_folder = strtr(
254
				rtrim($application_folder, '/\\'),
255
				'/\\',
256
				DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
257
			);
258
		}
259
	}
260 View Code Duplication
	elseif (is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
261
	{
262
		$application_folder = BASEPATH.strtr(
263
			trim($application_folder, '/\\'),
264
			'/\\',
265
			DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
266
		);
267
	}
268
	else
269
	{
270
		header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
271
		echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
272
		exit(3); // EXIT_CONFIG
273
	}
274
275
	define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
276
277
	// The path to the "views" directory
278
	if ( ! isset($view_folder[0]) && is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
279
	{
280
		$view_folder = APPPATH.'views';
281
	}
282 View Code Duplication
	elseif (is_dir($view_folder))
283
	{
284
		if (($_temp = realpath($view_folder)) !== FALSE)
285
		{
286
			$view_folder = $_temp;
287
		}
288
		else
289
		{
290
			$view_folder = strtr(
291
				rtrim($view_folder, '/\\'),
292
				'/\\',
293
				DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
294
			);
295
		}
296
	}
297 View Code Duplication
	elseif (is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
298
	{
299
		$view_folder = APPPATH.strtr(
300
			trim($view_folder, '/\\'),
301
			'/\\',
302
			DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
303
		);
304
	}
305
	else
306
	{
307
		header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
308
		echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
309
		exit(3); // EXIT_CONFIG
310
	}
311
312
	define('VIEWPATH', $view_folder.DIRECTORY_SEPARATOR);
313
314
/*
315
 * -------------------------------------------------------------------
316
 *  Enabling Monkey Patching
317
 * -------------------------------------------------------------------
318
 * 
319
 * If you want to use monkey patching, uncomment below code and configure
320
 * for your application.
321
 */
322
/*
323
require __DIR__ . '/_ci_phpunit_test/patcher/bootstrap.php';
324
MonkeyPatchManager::init([
325
	// PHP Parser: PREFER_PHP7, PREFER_PHP5, ONLY_PHP7, ONLY_PHP5
326
	'php_parser' => 'PREFER_PHP5',
327
	'cache_dir' => APPPATH . 'tests/_ci_phpunit_test/tmp/cache',
328
	// Directories to patch source files
329
	'include_paths' => [
330
		APPPATH,
331
		BASEPATH,
332
		APPPATH . 'tests/_ci_phpunit_test/replacing/',
333
	],
334
	// Excluding directories to patch
335
	// If you want to patch files inside paths below, you must add the directory starting with '-'
336
	'exclude_paths' => [
337
		APPPATH . 'tests/',
338
		'-' . APPPATH . 'tests/_ci_phpunit_test/replacing/',
339
	],
340
	// All patchers you use.
341
	'patcher_list' => [
342
		'ExitPatcher',
343
		'FunctionPatcher',
344
		'MethodPatcher',
345
		'ConstantPatcher',
346
	],
347
	// Additional functions to patch
348
	'functions_to_patch' => [
349
		//'random_string',
350
	],
351
	'exit_exception_classname' => 'CIPHPUnitTestExitException',
352
]);
353
*/
354
355
/*
356
 * -------------------------------------------------------------------
357
 *  Added for ci-phpunit-test
358
 * -------------------------------------------------------------------
359
 */
360
require __DIR__ . '/_ci_phpunit_test/CIPHPUnitTest.php';
361
CIPHPUnitTest::init();
362
/*
363
 * Or you can set directories for autoloading
364
 */
365
/*
366
CIPHPUnitTest::init([
367
	// Directories for autoloading
368
	APPPATH.'models',
369
	APPPATH.'libraries',
370
	APPPATH.'controllers',
371
	APPPATH.'modules',
372
]);
373
*/
374