diff --git a/bin/mftf b/bin/mftf index ef96ecca0..13d6ca7d1 100755 --- a/bin/mftf +++ b/bin/mftf @@ -12,7 +12,7 @@ if (PHP_SAPI !== 'cli') { } $autoloadPath = realpath(__DIR__ . '/../../../autoload.php'); -$testBootstrapPath = realpath(__DIR__ . '/../dev/tests/functional/_bootstrap.php'); +$testBootstrapPath = realpath(__DIR__ . '/../dev/tests/functional/standalone_bootstrap.php'); try { if (file_exists($autoloadPath)) { diff --git a/dev/tests/functional/_bootstrap.php b/dev/tests/functional/standalone_bootstrap.php similarity index 72% rename from dev/tests/functional/_bootstrap.php rename to dev/tests/functional/standalone_bootstrap.php index b724f1f86..8dd490396 100755 --- a/dev/tests/functional/_bootstrap.php +++ b/dev/tests/functional/standalone_bootstrap.php @@ -12,31 +12,31 @@ } defined('PROJECT_ROOT') || define('PROJECT_ROOT', dirname(dirname(dirname(__DIR__)))); + require_once realpath(PROJECT_ROOT . '/vendor/autoload.php'); //Load constants from .env file -defined('FW_BP') || define('FW_BP', PROJECT_ROOT); - -// add the debug flag here -$debug_mode = $_ENV['MFTF_DEBUG'] ?? false; -if (!(bool)$debug_mode && extension_loaded('xdebug')) { - xdebug_disable(); -} - -$RELATIVE_TESTS_MODULE_PATH = '/tests/functional/tests/MFTF'; - -defined('MAGENTO_BP') || define('MAGENTO_BP', PROJECT_ROOT); -defined('TESTS_BP') || define('TESTS_BP', dirname(dirname(__DIR__))); -defined('TESTS_MODULE_PATH') || define('TESTS_MODULE_PATH', realpath(TESTS_BP . $RELATIVE_TESTS_MODULE_PATH)); - -if (file_exists(TESTS_BP . DIRECTORY_SEPARATOR . '.env')) { - $env = new \Dotenv\Loader(TESTS_BP . DIRECTORY_SEPARATOR . '.env'); +$envFilePath = dirname(dirname(__DIR__)); +if (file_exists($envFilePath . DIRECTORY_SEPARATOR . '.env')) { + $env = new \Dotenv\Loader($envFilePath . DIRECTORY_SEPARATOR . '.env'); $env->load(); foreach ($_ENV as $key => $var) { defined($key) || define($key, $var); } + if (array_key_exists('MAGENTO_BP', $_ENV)) { + // 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/FunctionalTest'; + defined('TESTS_MODULE_PATH') || define( + 'TESTS_MODULE_PATH', + realpath(TESTS_BP . $RELATIVE_TESTS_MODULE_PATH) + ); + } + defined('MAGENTO_CLI_COMMAND_PATH') || define( 'MAGENTO_CLI_COMMAND_PATH', 'dev/tests/acceptance/utils/command.php' @@ -56,3 +56,17 @@ } } + +defined('FW_BP') || define('FW_BP', PROJECT_ROOT); +defined('MAGENTO_BP') || define('MAGENTO_BP', PROJECT_ROOT); +defined('TESTS_BP') || define('TESTS_BP', dirname(dirname(__DIR__))); + +$RELATIVE_TESTS_MODULE_PATH = '/tests/functional/tests/MFTF'; +defined('TESTS_MODULE_PATH') || define('TESTS_MODULE_PATH', realpath(TESTS_BP . $RELATIVE_TESTS_MODULE_PATH)); + + +// add the debug flag here +$debug_mode = $_ENV['MFTF_DEBUG'] ?? false; +if (!(bool)$debug_mode && extension_loaded('xdebug')) { + xdebug_disable(); +} diff --git a/src/Magento/FunctionalTestingFramework/_bootstrap.php b/src/Magento/FunctionalTestingFramework/_bootstrap.php index d477477dc..85e88fc09 100644 --- a/src/Magento/FunctionalTestingFramework/_bootstrap.php +++ b/src/Magento/FunctionalTestingFramework/_bootstrap.php @@ -7,22 +7,17 @@ // define framework basepath for schema pathing defined('FW_BP') || define('FW_BP', realpath(__DIR__ . '/../../../')); - -// get the root path of the project (we will always be installed under vendor) +// 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/_bootstrap.php")); + 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/'); -// set Magento_BP as Root_Project Path -define('PROJECT_ROOT', $projectRootPath); -defined('MAGENTO_BP') || define('MAGENTO_BP', realpath($projectRootPath)); -// load .env (if it exists) -$envFilepath = realpath(MAGENTO_BP . '/dev/tests/acceptance/'); if (file_exists($envFilepath . DIRECTORY_SEPARATOR . '.env')) { $env = new \Dotenv\Loader($envFilepath . DIRECTORY_SEPARATOR . '.env'); $env->load(); @@ -56,6 +51,8 @@ } } + +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/'));