-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbootstrap.php
49 lines (42 loc) · 1.22 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
<?php
declare(strict_types=1);
use Cake\Datasource\ConnectionManager;
use Cake\TestSuite\Fixture\SchemaLoader;
use function Cake\Core\env;
/**
* Test suite bootstrap.
*
* This function is used to find the location of CakePHP whether CakePHP
* has been installed as a dependency of the plugin, or the plugin is itself
* installed as a dependency of an application.
*
* @throws \Exception
*/
$findRoot = function ($root) {
do {
$lastRoot = $root;
$root = dirname($root);
if (is_dir($root . '/vendor/cakephp/cakephp')) {
return $root;
}
} while ($root !== $lastRoot);
throw new Exception('Cannot find the root of the application, unable to run tests');
};
$root = $findRoot(__FILE__);
unset($findRoot);
chdir($root);
if (file_exists($root . '/config/bootstrap.php')) {
require $root . '/config/bootstrap.php';
return;
}
require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php';
$dbConfig = [
'url' => env('DB_URL'),
];
ConnectionManager::drop('test');
ConnectionManager::setConfig('test', $dbConfig);
// Create test database schema
if (env('FIXTURE_SCHEMA_METADATA')) {
$loader = new SchemaLoader();
$loader->loadInternalFile(env('FIXTURE_SCHEMA_METADATA'));
}