This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbootstrap.php
129 lines (111 loc) · 3.66 KB
/
bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
* Prepares a minimalist framework for unit testing.
*
* Joomla is assumed to include the /unittest/ directory.
* eg, /path/to/joomla/unittest/
*
* @package Joomla.UnitTest
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @link http://www.phpunit.de/manual/current/en/installation.html
*/
/**
* Mock for the global application exit.
*
* @param mixed $message Exit code or string. Defaults to zero.
*
* @return void
*/
function jexit($message = 0)
{
}
define('_JEXEC', 1);
// Fix magic quotes.
ini_set('magic_quotes_runtime', 0);
// Maximise error reporting.
ini_set('zend.ze1_compatibility_mode', '0');
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Set fixed precision value to avoid round related issues
ini_set('precision', 14);
/*
* Ensure that required path constants are defined. These can be overridden within the phpunit.xml file
* if you chose to create a custom version of that file.
*/
if (!defined('JPATH_TESTS')) {
define('JPATH_TESTS', realpath(__DIR__));
}
if (!defined('JPATH_TEST_DATABASE')) {
define('JPATH_TEST_DATABASE', JPATH_TESTS . '/stubs/database');
}
if (!defined('JPATH_TEST_STUBS')) {
define('JPATH_TEST_STUBS', JPATH_TESTS . '/stubs');
}
$rootDirectory = getcwd();
if (!defined('JPATH_BASE')) {
define('JPATH_BASE', $rootDirectory);
}
if (!defined('JPATH_ROOT')) {
define('JPATH_ROOT', JPATH_BASE);
}
if (!defined('JPATH_PLATFORM')) {
define('JPATH_PLATFORM', JPATH_BASE . '/libraries');
}
if (!defined('JPATH_LIBRARIES')) {
define('JPATH_LIBRARIES', JPATH_BASE . '/libraries');
}
if (!defined('JPATH_CACHE')) {
define('JPATH_CACHE', JPATH_BASE . '/cache');
}
if (!defined('JPATH_CONFIGURATION')) {
define('JPATH_CONFIGURATION', JPATH_BASE);
}
if (!defined('JPATH_SITE')) {
define('JPATH_SITE', JPATH_ROOT);
}
if (!defined('JPATH_ADMINISTRATOR')) {
define('JPATH_ADMINISTRATOR', JPATH_ROOT . '/administrator');
}
if (!defined('JPATH_INSTALLATION')) {
define('JPATH_INSTALLATION', JPATH_ROOT . '/installation');
}
if (!defined('JPATH_MANIFESTS')) {
define('JPATH_MANIFESTS', JPATH_ADMINISTRATOR . '/manifests');
}
if (!defined('JPATH_PLUGINS')) {
define('JPATH_PLUGINS', JPATH_BASE . '/plugins');
}
if (!defined('JPATH_THEMES')) {
define('JPATH_THEMES', JPATH_BASE . '/templates');
}
if (!defined('JDEBUG')) {
define('JDEBUG', false);
}
// Import the library loader if necessary.
if (!class_exists('JLoader')) {
require_once JPATH_PLATFORM . '/loader.php';
// If JLoader still does not exist panic.
if (!class_exists('JLoader')) {
throw new RuntimeException('Joomla Platform not loaded.');
}
}
// Setup the autoloaders.
JLoader::setup();
// Register the library base path for CMS libraries.
JLoader::registerPrefix('J', JPATH_PLATFORM . '/cms', false, true);
// Register the extension root paths.
JLoader::registerExtensionRootFolder('', JPATH_SITE);
JLoader::registerExtensionRootFolder('Site', JPATH_SITE);
JLoader::registerExtensionRootFolder('Administrator', JPATH_ADMINISTRATOR);
// Create the Composer autoloader
/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require JPATH_LIBRARIES . '/vendor/autoload.php';
$loader->unregister();
// Decorate Composer autoloader
spl_autoload_register([new JClassLoader($loader), 'loadClass'], true, true);
// Register the class aliases for Framework classes that have replaced their Platform equivilents
require_once JPATH_LIBRARIES . '/classmap.php';
// Define the Joomla version if not already defined.
defined('JVERSION') or define('JVERSION', (new JVersion)->getShortVersion());