Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
bootstrap.php
Go to the documentation of this file.
1 <?php
8 
9 require_once __DIR__ . '/../../../../app/bootstrap.php';
10 require_once __DIR__ . '/autoload.php';
11 //to handle different types of errors on CI
12 require __DIR__ . '/../../error_handler.php';
13 
15 $integrationTestsDir = realpath("{$testsBaseDir}/../integration");
17 
18 if (!defined('TESTS_BASE_DIR')) {
19  define('TESTS_BASE_DIR', $testsBaseDir);
20 }
21 
22 if (!defined('TESTS_TEMP_DIR')) {
23  define('TESTS_TEMP_DIR', $testsBaseDir . '/tmp');
24 }
25 
26 if (!defined('TESTS_MODULES_PATH')) {
27  define('TESTS_MODULES_PATH', $testsBaseDir . '/_files');
28 }
29 
30 if (!defined('MAGENTO_MODULES_PATH')) {
31  define('MAGENTO_MODULES_PATH', __DIR__ . '/../../../../app/code/Magento/');
32 }
33 $settings = new \Magento\TestFramework\Bootstrap\Settings($testsBaseDir, get_defined_constants());
34 
35 
36 try {
38  $installConfigFile = $settings->getAsConfigFile('TESTS_INSTALL_CONFIG_FILE');
39  if (!file_exists($installConfigFile)) {
40  $installConfigFile .= '.dist';
41  }
42  if (!defined('TESTS_INSTALLATION_DB_CONFIG_FILE')) {
43  define('TESTS_INSTALLATION_DB_CONFIG_FILE', $installConfigFile);
44  }
45  /* Bootstrap the application */
46  $shell = new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer());
48 
49  $globalConfigFile = $settings->getAsConfigFile('TESTS_GLOBAL_CONFIG_FILE');
50  if (!file_exists($globalConfigFile)) {
51  $globalConfigFile .= '.dist';
52  }
53 
55  $installDir = TESTS_TEMP_DIR;
56  $application = new \Magento\TestFramework\SetupApplication(
57  $shell,
61  $settings->get('TESTS_GLOBAL_CONFIG_DIR'),
62  $settings->get('TESTS_MAGENTO_MODE'),
63  AutoloaderRegistry::getAutoloader(),
64  false
65  );
66 
67  $bootstrap = new \Magento\TestFramework\Bootstrap(
68  $settings,
69  new \Magento\TestFramework\Bootstrap\Environment(),
70  new \Magento\TestFramework\Bootstrap\SetupDocBlock("{$testsBaseDir}/_files/"),
71  new \Magento\TestFramework\Bootstrap\Profiler(new \Magento\Framework\Profiler\Driver\Standard()),
72  $shell,
74  new \Magento\TestFramework\Bootstrap\MemoryFactory($shell)
75  );
76  //remove test modules files
77  include_once __DIR__ . '/../../setup-integration/framework/removeTestModules.php';
78  $bootstrap->runBootstrap();
79  $application->createInstallDir();
80  //We do not want to install anything
81  $application->initialize([]);
82  $application->cleanup();
83 
84  \Magento\TestFramework\Helper\Bootstrap::setInstance(new \Magento\TestFramework\Helper\Bootstrap($bootstrap));
85 
87  ->create(\Magento\Framework\Component\DirSearch::class);
89  ->create(\Magento\Framework\View\Design\Theme\ThemePackageList::class);
91  new Magento\Framework\App\Utility\Files(
92  new \Magento\Framework\Component\ComponentRegistrar(),
93  $dirSearch,
95  )
96  );
97 
98  /* Unset declared global variables to release the PHPUnit from maintaining their values between tests */
99  unset($testsBaseDir, $logWriter, $settings, $shell, $application, $bootstrap);
100 } catch (\Exception $e) {
101  echo $e . PHP_EOL;
102  exit(1);
103 }
if(!file_exists($installConfigFile)) $dirList
Definition: bootstrap.php:57
$fixtureBaseDir
Definition: bootstrap.php:15
return false
Definition: gallery.phtml:36
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
if(!file_exists($installConfigFile)) if(!defined('TESTS_INSTALLATION_DB_CONFIG_FILE')) $shell
Definition: bootstrap.php:46
$testsBaseDir
Definition: bootstrap.php:13
$installDir
Definition: bootstrap.php:55
$themePackageList
Definition: bootstrap.php:88
if(defined('TESTS_MAGENTO_INSTALLATION') &&TESTS_MAGENTO_INSTALLATION==='enabled') $bootstrap
Definition: bootstrap.php:73
$application
Definition: bootstrap.php:58
if(!file_exists($installConfigFile)) $globalConfigFile
Definition: bootstrap.php:53
static setInstance(Files $instance=null)
Definition: Files.php:136
$dirSearch
Definition: bootstrap.php:86
exit
Definition: redirect.phtml:12
$integrationTestsDir
Definition: bootstrap.php:14
$settings
Definition: bootstrap.php:29
const BP
Definition: autoload.php:14
catch(\Exception $e) setCustomErrorHandler()
Definition: bootstrap.php:106
static setInstance(\Magento\TestFramework\Helper\Bootstrap $instance)
Definition: Bootstrap.php:35
$testFrameworkDir
Definition: bootstrap.php:46
$installConfigFile
Definition: bootstrap.php:49