-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbootstrap.php
More file actions
69 lines (55 loc) · 1.67 KB
/
Copy pathbootstrap.php
File metadata and controls
69 lines (55 loc) · 1.67 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
<?php
declare(strict_types=1);
/**
* Test suite bootstrap for TwoFactorAuth.
*
* 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.
*/
use Authentication\AuthenticationPlugin;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\TestSuite\Fixture\SchemaLoader;
$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);
require_once $root . '/vendor/autoload.php';
/**
* Define fallback values for required constants and configuration.
* To customize constants and configuration remove this require
* and define the data required by your plugin here.
*/
require_once $root . '/vendor/cakephp/cakephp/tests/bootstrap.php';
if (file_exists($root . '/config/bootstrap.php')) {
include $root . '/config/bootstrap.php';
return;
}
Configure::write(
'App',
[
'namespace' => 'TwoFactorAuth',
'paths' => [
'plugins' => [ROOT . 'Plugin' . DS],
'templates' => [ROOT . 'templates' . DS],
],
'encoding' => 'UTF-8',
],
);
if (!getenv('db_dsn')) {
putenv('db_dsn=sqlite:///:memory:');
}
Plugin::getCollection()->add(new AuthenticationPlugin());
$_SERVER['PHP_SELF'] = '/';
$loader = new SchemaLoader();
$loader->loadInternalFile(__DIR__ . '/schema.php');