/** * Perform bootstrap actions required to completely setup the testing environment */ public function runBootstrap() { $this->_envBootstrap->emulateHttpRequest($_SERVER); $this->_envBootstrap->emulateSession($_SESSION); $profilerOutputFile = $this->_settings->getAsFile('TESTS_PROFILER_FILE'); if ($profilerOutputFile) { $this->_profilerBootstrap->registerFileProfiler($profilerOutputFile); } $profilerOutputFile = $this->_settings->getAsFile('TESTS_BAMBOO_PROFILER_FILE'); $profilerMetricsFile = $this->_settings->getAsFile('TESTS_BAMBOO_PROFILER_METRICS_FILE'); if ($profilerOutputFile && $profilerMetricsFile) { $this->_profilerBootstrap->registerBambooProfiler($profilerOutputFile, $profilerMetricsFile); } $memoryBootstrap = $this->_createMemoryBootstrap($this->_settings->get('TESTS_MEM_USAGE_LIMIT', 0), $this->_settings->get('TESTS_MEM_LEAK_LIMIT', 0)); $memoryBootstrap->activateStatsDisplaying(); $memoryBootstrap->activateLimitValidation(); $this->_docBlockBootstrap->registerAnnotations($this->_application); if ($this->_settings->getAsBoolean('TESTS_CLEANUP')) { $this->_application->cleanup(); } if ($this->_application->isInstalled()) { $this->_application->initialize(); } else { $this->_application->install(self::ADMIN_NAME, self::ADMIN_PASSWORD, self::ADMIN_ROLE_NAME); } }
$application = new Application($shell, $installDir, $installConfigFile, $globalConfigFile, $settings->get('TESTS_GLOBAL_CONFIG_DIR'), $settings->get('TESTS_MAGENTO_MODE'), AutoloaderRegistry::getAutoloader()); // Create a bootstrapper which will do most of the work of setting up the // M2 environment for the application to run. $bootstrap = new Bootstrap($settings, new Environment(), new BehatDocBlock("{$testsBaseDir}/testsuite"), new Profiler(new StandardProfilerDriver()), $shell, $application, new MemoryFactory($shell)); // Setup for environment HTTP and session emulation, profiling, memory // limits, and event registration (through a somewhat dubious side-effect // of DocBlock annotation registration). $bootstrap->runBootstrap(); // cleanup and install ensure the M2 environment is clean before running // tests - uninstalls M2 and then reinstalls it using the test configuration. // @TODO This may need to be extended to also include any initial data needed // for the tests. if ($settings->getAsBoolean('TESTS_CLEANUP')) { $application->cleanup(); } if (!$application->isInstalled()) { $application->install(); } // Initialize the application. Largely responsible for setting up the // object manager instance - including updating relevant configuration for // the object manager to use test configuration - and replacing some // dependencies from the core Magento framework with alternatives from the // test framework. $application->initialize(); BootstrapHelper::setInstance(new BootstrapHelper($bootstrap)); AppFilesUtility::setInstance(new AppFilesUtility($magentoBaseDir)); } catch (\Exception $e) { echo $e . PHP_EOL; exit(1); } });