/** * @depends testSetInstanceFirstAllowed * @expectedException \Magento\Framework\Exception\LocalizedException * @expectedExceptionMessage Helper instance cannot be redefined. */ public function testSetInstanceChangeProhibited() { \Magento\TestFramework\Helper\Bootstrap::setInstance($this->_object); }
} else { $shell = new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer()); } $installConfigFile = $settings->getAsConfigFile('TESTS_INSTALL_CONFIG_FILE'); if (!file_exists($installConfigFile)) { $installConfigFile .= '.dist'; } $globalConfigFile = $settings->getAsConfigFile('TESTS_GLOBAL_CONFIG_FILE'); if (!file_exists($globalConfigFile)) { $globalConfigFile .= '.dist'; } $sandboxUniqueId = md5(sha1_file($installConfigFile)); $installDir = TESTS_TEMP_DIR . "/sandbox-{$settings->get('TESTS_PARALLEL_THREAD', 0)}-{$sandboxUniqueId}"; $application = new \Magento\TestFramework\Application($shell, $installDir, $installConfigFile, $globalConfigFile, $settings->get('TESTS_GLOBAL_CONFIG_DIR'), $settings->get('TESTS_MAGENTO_MODE'), AutoloaderRegistry::getAutoloader(), true); $bootstrap = new \Magento\TestFramework\Bootstrap($settings, new \Magento\TestFramework\Bootstrap\Environment(), new \Magento\TestFramework\Bootstrap\DocBlock("{$testsBaseDir}/testsuite"), new \Magento\TestFramework\Bootstrap\Profiler(new \Magento\Framework\Profiler\Driver\Standard()), $shell, $application, new \Magento\TestFramework\Bootstrap\MemoryFactory($shell)); $bootstrap->runBootstrap(); if ($settings->getAsBoolean('TESTS_CLEANUP')) { $application->cleanup(); } if (!$application->isInstalled()) { $application->install(); } $application->initialize([]); \Magento\TestFramework\Helper\Bootstrap::setInstance(new \Magento\TestFramework\Helper\Bootstrap($bootstrap)); \Magento\Framework\App\Utility\Files::setInstance(new Magento\Framework\App\Utility\Files($magentoBaseDir)); /* Unset declared global variables to release the PHPUnit from maintaining their values between tests */ unset($testsBaseDir, $magentoBaseDir, $logWriter, $settings, $shell, $application, $bootstrap); } catch (\Exception $e) { echo $e . PHP_EOL; exit(1); }
$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); } });