-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy path_bootstrap.php
82 lines (70 loc) · 3.14 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
<?php
// @codingStandardsIgnoreFile
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// define framework basepath for schema pathing
use Symfony\Component\Dotenv\Exception\PathException;
defined('FW_BP') || define('FW_BP', realpath(__DIR__ . '/../../../'));
// get the root path of the project
$projectRootPath = substr(FW_BP, 0, strpos(FW_BP, DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR));
if (empty($projectRootPath)) {
// If ProjectRootPath is empty, we are not under vendor and are executing standalone.
require_once (realpath(FW_BP . "/dev/tests/functional/standalone_bootstrap.php"));
return;
}
defined('PROJECT_ROOT') || define('PROJECT_ROOT', $projectRootPath);
$envFilePath = realpath($projectRootPath . '/dev/tests/acceptance/') . DIRECTORY_SEPARATOR;
defined('ENV_FILE_PATH') || define('ENV_FILE_PATH', $envFilePath);
//Load constants from .env file
if (file_exists(ENV_FILE_PATH . '.env')) {
$env = new \Symfony\Component\Dotenv\Dotenv();
if (function_exists('putenv')) {
$env->usePutenv();
}
$env->populate($env->parse(file_get_contents(ENV_FILE_PATH . '.env'), ENV_FILE_PATH . '.env'), true);
if (array_key_exists('TESTS_MODULE_PATH', $_ENV) xor array_key_exists('TESTS_BP', $_ENV)) {
throw new Exception(
'You must define both parameters TESTS_BP and TESTS_MODULE_PATH or neither parameter'
);
}
foreach ($_ENV as $key => $var) {
defined($key) || define($key, $var);
}
if (array_key_exists('MAGENTO_BP', $_ENV)) {
defined('TESTS_BP') || define('TESTS_BP', realpath(PROJECT_ROOT . DIRECTORY_SEPARATOR . 'dev/tests/acceptance'));
}
defined('MAGENTO_CLI_COMMAND_PATH') || define(
'MAGENTO_CLI_COMMAND_PATH',
'dev/tests/acceptance/utils/command.php'
);
defined('MAGENTO_CLI_COMMAND_PARAMETER') || define('MAGENTO_CLI_COMMAND_PARAMETER', 'command');
defined('DEFAULT_TIMEZONE') || define('DEFAULT_TIMEZONE', 'America/Los_Angeles');
defined('WAIT_TIMEOUT') || define('WAIT_TIMEOUT', 30);
defined('VERBOSE_ARTIFACTS') || define('VERBOSE_ARTIFACTS', false);
$env->populate(
[
'MAGENTO_CLI_COMMAND_PATH' => MAGENTO_CLI_COMMAND_PATH,
'MAGENTO_CLI_COMMAND_PARAMETER' => MAGENTO_CLI_COMMAND_PARAMETER,
'DEFAULT_TIMEZONE' => DEFAULT_TIMEZONE,
'WAIT_TIMEOUT' => WAIT_TIMEOUT,
'VERBOSE_ARTIFACTS' => VERBOSE_ARTIFACTS,
],
true
);
try {
new DateTimeZone(DEFAULT_TIMEZONE);
} catch (\Exception $e) {
throw new \Exception("Invalid DEFAULT_TIMEZONE in .env: " . DEFAULT_TIMEZONE . PHP_EOL);
}
}
defined('MAGENTO_BP') || define('MAGENTO_BP', realpath(PROJECT_ROOT));
// TODO REMOVE THIS CODE ONCE WE HAVE STOPPED SUPPORTING dev/tests/acceptance PATH
// define TEST_PATH and TEST_MODULE_PATH
defined('TESTS_BP') || define('TESTS_BP', realpath(MAGENTO_BP . DIRECTORY_SEPARATOR . 'dev/tests/acceptance'));
$RELATIVE_TESTS_MODULE_PATH = '/tests/functional/Magento';
defined('TESTS_MODULE_PATH') || define(
'TESTS_MODULE_PATH',
realpath(TESTS_BP . $RELATIVE_TESTS_MODULE_PATH)
);