Esempio n. 1
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);
     }
 }
Esempio n. 2
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);
     }
     $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 mixed $defaultValue
  * @param mixed $expectedResult
  * @dataProvider getDataProvider
  */
 public function testGet($settingName, $defaultValue, $expectedResult)
 {
     $this->assertSame($expectedResult, $this->_object->get($settingName, $defaultValue));
 }
 // 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)) {
     $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();