-
Notifications
You must be signed in to change notification settings - Fork 566
Expand file tree
/
Copy pathbootstrap.php
More file actions
126 lines (112 loc) · 3.48 KB
/
bootstrap.php
File metadata and controls
126 lines (112 loc) · 3.48 KB
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
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @license https://www.opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Cache\Cache;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Datasource\ConnectionManager;
use Cake\Log\Log;
use Cake\TestSuite\Fixture\SchemaLoader;
use DebugKit\DebugKitPlugin;
use function Cake\Core\env;
require_once 'vendor/autoload.php';
// Path constants to a few helpful things.
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
define('ROOT', dirname(__DIR__));
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'vendor' . DS . 'cakephp' . DS . 'cakephp');
define('CORE_PATH', ROOT . DS . 'vendor' . DS . 'cakephp' . DS . 'cakephp' . DS);
define('CAKE', CORE_PATH . 'src' . DS);
define('TESTS', ROOT . DS . 'tests');
define('APP', ROOT . DS . 'tests' . DS . 'test_app' . DS);
define('APP_DIR', 'test_app');
define('WEBROOT_DIR', 'webroot');
define('WWW_ROOT', APP . 'webroot' . DS);
define('TMP', sys_get_temp_dir() . DS);
define('CONFIG', APP . 'config' . DS);
define('CACHE', TMP);
define('LOGS', TMP);
require_once CORE_PATH . 'config/bootstrap.php';
require_once CAKE . 'functions.php';
date_default_timezone_set('UTC');
mb_internal_encoding('UTF-8');
Configure::write('debug', true);
Configure::write('App', [
'namespace' => 'DebugKit\TestApp',
'encoding' => 'UTF-8',
'base' => false,
'baseUrl' => false,
'dir' => 'src',
'webroot' => 'webroot',
'www_root' => APP . 'webroot',
'fullBaseUrl' => 'http://localhost',
'imageBaseUrl' => 'img/',
'jsBaseUrl' => 'js/',
'cssBaseUrl' => 'css/',
'paths' => [
'plugins' => [APP . 'Plugin' . DS],
'templates' => [APP . 'templates' . DS],
],
]);
Configure::write('Session', [
'defaults' => 'php',
]);
Cache::setConfig([
'_cake_translations_' => [
'engine' => 'File',
'prefix' => 'cake_translations_',
'serialize' => true,
],
'_cake_model_' => [
'engine' => 'File',
'prefix' => 'cake_model_',
'serialize' => true,
],
'default' => [
'engine' => 'File',
'prefix' => 'default_',
'serialize' => true,
],
]);
// Ensure default test connection is defined
if (!getenv('DB_URL')) {
putenv('DB_URL=sqlite://127.0.0.1/' . TMP . 'debug_kit_test.sqlite');
}
$config = [
'url' => getenv('DB_URL'),
'timezone' => 'UTC',
];
// Use the test connection for 'debug_kit' as well.
ConnectionManager::setConfig('test', $config);
ConnectionManager::setConfig('test_debug_kit', $config);
Log::setConfig([
'debug' => [
'engine' => 'Cake\Log\Engine\FileLog',
'path' => LOGS,
'levels' => ['notice', 'info', 'debug'],
'file' => 'debug',
],
'error' => [
'engine' => 'Cake\Log\Engine\FileLog',
'path' => LOGS,
'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
'file' => 'error',
],
]);
Plugin::getCollection()->add(new DebugKitPlugin());
// Create test database schema
if (env('FIXTURE_SCHEMA_METADATA')) {
$loader = new SchemaLoader();
$loader->loadInternalFile(env('FIXTURE_SCHEMA_METADATA'), 'test');
}