本文整理匯總了PHP中Magento\TestFramework\Helper\Bootstrap::setInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Bootstrap::setInstance方法的具體用法?PHP Bootstrap::setInstance怎麽用?PHP Bootstrap::setInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\TestFramework\Helper\Bootstrap
的用法示例。
在下文中一共展示了Bootstrap::setInstance方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSetInstanceChangeProhibited
/**
* @depends testSetInstanceFirstAllowed
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage Helper instance cannot be redefined.
*/
public function testSetInstanceChangeProhibited()
{
\Magento\TestFramework\Helper\Bootstrap::setInstance($this->_object);
}
示例2: md5
} 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);
}
示例3: Application
$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);
}
});