/**
  * Isolate global application objects
  */
 protected function _isolateApp()
 {
     if ($this->_hasNonIsolatedTests) {
         $this->_application->reinitialize();
         $this->_hasNonIsolatedTests = false;
     }
 }
Beispiel #2
0
 /**
  * Run entire test suite of scenarios
  */
 public function run()
 {
     $this->_reportFiles = [];
     $scenarios = $this->_getOptimizedScenarioList();
     foreach ($scenarios as $scenario) {
         /** @var $scenario \Magento\TestFramework\Performance\Scenario */
         $this->_application->applyFixtures($scenario->getFixtures());
         $this->_notifyScenarioRun($scenario);
         /* warm up cache, if any */
         $settings = $scenario->getSettings();
         if (empty($settings[self::SETTING_SKIP_WARM_UP])) {
             try {
                 $scenarioWarmUp = new \Magento\TestFramework\Performance\Scenario($scenario->getTitle(), $scenario->getFile(), $this->_warmUpArguments + $scenario->getArguments(), $scenario->getSettings(), $scenario->getFixtures());
                 $this->_scenarioHandler->run($scenarioWarmUp);
             } catch (\Magento\TestFramework\Performance\Scenario\FailureException $scenarioFailure) {
                 // do not notify about failed warm up
             }
         }
         /* full run with reports recording */
         $reportFile = $this->_getScenarioReportFile($scenario);
         try {
             $this->_scenarioHandler->run($scenario, $reportFile);
         } catch (\Magento\TestFramework\Performance\Scenario\FailureException $scenarioFailure) {
             $this->_notifyScenarioFailure($scenarioFailure);
         }
     }
 }
 /**
  * Start test case event observer
  *
  * @param \PHPUnit_Framework_TestCase $test
  */
 public function startTest(\PHPUnit_Framework_TestCase $test)
 {
     $area = $this->_getTestAppArea($test->getAnnotations());
     if ($this->_application->getArea() !== $area) {
         $this->_application->reinitialize();
         if ($this->_application->getArea() !== $area) {
             $this->_application->loadArea($area);
         }
     }
 }
Beispiel #4
0
 /**
  * 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 testRunApp()
 {
     $this->_application->expects($this->once())->method('run');
     $this->_object->runApp();
 }
Beispiel #6
0
 /**
  * Test application reset
  */
 public function testAppReset()
 {
     $this->assertEquals(true, $this->_object->reset() instanceof \Magento\TestFramework\Application);
 }
 $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)) {
     $globalConfigFile .= '.dist';
 }
 // Create a sandbox directory for configuration, generated, cache, session
 // and related files created for the test context.
 $sandboxUniqueId = md5(sha1_file($installConfigFile));
 $installDir = "{$testsTmpDir}/sandbox-{$settings->get('TESTS_PARALLEL_THREAD', 0)}-{$sandboxUniqueId}";
 // Create the application - M2 application context for the test run.
 $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()) {