/** * 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); } }
public function testRunBootstrapProfilerEnabled() { $memoryBootstrap = $this->getMock('Magento\\TestFramework\\Bootstrap\\Memory', ['activateStatsDisplaying', 'activateLimitValidation'], [], '', false); $memoryBootstrap->expects($this->once())->method('activateStatsDisplaying'); $memoryBootstrap->expects($this->once())->method('activateLimitValidation'); $this->memoryFactory->expects($this->once())->method('create')->with(0, 0)->will($this->returnValue($memoryBootstrap)); $settingsMap = [['TESTS_PROFILER_FILE', '', 'profiler.csv'], ['TESTS_BAMBOO_PROFILER_FILE', '', 'profiler_bamboo.csv'], ['TESTS_BAMBOO_PROFILER_METRICS_FILE', '', 'profiler_metrics.php']]; $this->_settings->expects($this->any())->method('getAsFile')->will($this->returnValueMap($settingsMap)); $this->_profilerBootstrap->expects($this->once())->method('registerFileProfiler')->with("profiler.csv"); $this->_profilerBootstrap->expects($this->once())->method('registerBambooProfiler')->with("profiler_bamboo.csv", "profiler_metrics.php"); $this->_object->runBootstrap(); }
/** * 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); } $profilerBambooOutputFile = $this->_settings->getAsFile('TESTS_BAMBOO_PROFILER_FILE'); $profilerBambooMetricsFile = $this->_settings->getAsFile('TESTS_BAMBOO_PROFILER_METRICS_FILE'); if ($profilerBambooOutputFile && $profilerBambooMetricsFile) { $this->_profilerBootstrap->registerBambooProfiler($profilerBambooOutputFile, $profilerBambooMetricsFile); } $memoryBootstrap = $this->memoryFactory->create($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); }
/** * @param string $settingName * @param string $expectedExceptionMsg * @dataProvider getAsConfigFileExceptionDataProvider */ public function testGetAsConfigFileException($settingName, $expectedExceptionMsg) { $this->setExpectedException('Magento\\Framework\\Exception\\LocalizedException', $expectedExceptionMsg); $this->_object->getAsConfigFile($settingName); }
// // Additional configuration options available for the Magento Test Framework. // Some or all of these additional configurations may or may not be useful // for Behat integration tests. // // TESTS_PROFILER_FILE // => CSV file to write profiler information to // TESTS_MEM_USAGE_LIMIT // => memory usage limit // TEST_MEM_LEAK_LIMIT // => check for memory leaks // TESTS_ERROR_LOG_LISTENER_LEVEL // => Minimum error log level to listen for. Possible values: -1 ignore all errors, and level constants form http://tools.ietf.org/html/rfc5424 standard // TESTS_EXTRA_VERBOSE_LOG // => More verbose output $settings = new Settings(__DIR__, ['TESTS_INSTALL_CONFIG_FILE' => 'config' . DIRECTORY_SEPARATOR . 'install-config-mysql.php', 'TESTS_GLOBAL_CONFIG_FILE' => 'config' . DIRECTORY_SEPARATOR . 'config-global.php', 'TESTS_GLOBAL_CONFIG_DIR' => $magentoBaseDir . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'etc', 'TESTS_CLEANUP' => 'disabled', 'TESTS_MAGENTO_MODE' => 'developer']); // I think this is responsible for rendering test output. Not sure if it // is truly necessary with Behat tests or if this is really only needed for // Magento's integration tests. $shell = new Shell(new CommandRenderer()); // Configuration files specifically for the testing context. The // installConfigFile contains configuration for connecting to the test // database and accessing the admin. $installConfigFile = $settings->getAsConfigFile('TESTS_INSTALL_CONFIG_FILE'); if (!file_exists($installConfigFile)) { $installConfigFile .= '.dist'; } // Additional Magento configuration for the testing context. // @TODO What configuration can be set this way? $globalConfigFile = $settings->getAsConfigFile('TESTS_GLOBAL_CONFIG_FILE'); if (!file_exists($globalConfigFile)) {