protected function setUp() { $this->_application = $this->getMock('Magento\\TestFramework\\Application', ['getTempDir', 'getInitParams', 'reinitialize', 'run'], [], '', false); $this->_bootstrap = $this->getMock('Magento\\TestFramework\\Bootstrap', ['getApplication', 'getDbVendorName'], [], '', false); $this->_bootstrap->expects($this->any())->method('getApplication')->will($this->returnValue($this->_application)); $this->_object = new \Magento\TestFramework\Helper\Bootstrap($this->_bootstrap); }
public function testRunBootstrapAppInstall() { $adminUserName = \Magento\TestFramework\Bootstrap::ADMIN_NAME; $adminPassword = \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD; $adminRoleName = \Magento\TestFramework\Bootstrap::ADMIN_ROLE_NAME; $application = $this->_injectApplicationMock(); $application->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); $application->expects($this->once())->method('install')->with($adminUserName, $adminPassword, $adminRoleName); $application->expects($this->never())->method('initialize'); $application->expects($this->never())->method('cleanup'); $this->_object->runBootstrap(); }
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 the full request processing by the application instance. * Intended to be used by the controller tests. */ public function runApp() { $this->_bootstrap->getApplication()->run(); }
} // 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()) { $application->install(); } // Initialize the application. Largely responsible for setting up the
public function testGetDbVendorName() { $this->_bootstrap->expects($this->once())->method('getDbVendorName')->will($this->returnValue('mysql')); $this->assertEquals('mysql', $this->_object->getDbVendorName()); }