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
9 
10 require_once __DIR__ . '/../../../../app/bootstrap.php';
11 require_once __DIR__ . '/autoload.php';
12 
14 $integrationTestsDir = realpath("{$testsBaseDir}/../integration");
16 
17 if (!defined('TESTS_TEMP_DIR')) {
18  define('TESTS_TEMP_DIR', $testsBaseDir . '/tmp');
19 }
20 
21 if (!defined('INTEGRATION_TESTS_DIR')) {
22  define('INTEGRATION_TESTS_DIR', $integrationTestsDir);
23 }
24 
25 try {
27 
28  /* Bootstrap the application */
29  $settings = new \Magento\TestFramework\Bootstrap\Settings($testsBaseDir, get_defined_constants());
30 
31  if ($settings->get('TESTS_EXTRA_VERBOSE_LOG')) {
32  $filesystem = new \Magento\Framework\Filesystem\Driver\File();
33  $exceptionHandler = new \Magento\Framework\Logger\Handler\Exception($filesystem);
34  $loggerHandlers = [
35  'system' => new \Magento\Framework\Logger\Handler\System($filesystem, $exceptionHandler),
36  'debug' => new \Magento\Framework\Logger\Handler\Debug($filesystem)
37  ];
38  $shell = new \Magento\Framework\Shell(
39  new \Magento\Framework\Shell\CommandRenderer(),
40  new \Monolog\Logger('main', $loggerHandlers)
41  );
42  } else {
43  $shell = new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer());
44  }
45 
47  require_once INTEGRATION_TESTS_DIR . '/framework/deployTestModules.php';
48 
49  $installConfigFile = $settings->getAsConfigFile('TESTS_INSTALL_CONFIG_FILE');
50  if (!file_exists($installConfigFile)) {
52  }
53  $globalConfigFile = $settings->getAsConfigFile('TESTS_GLOBAL_CONFIG_FILE');
54  if (!file_exists($installConfigFile)) {
56  }
57  $dirList = new \Magento\Framework\App\Filesystem\DirectoryList(BP);
58  $application = new \Magento\TestFramework\WebApiApplication(
59  $shell,
60  $dirList->getPath(DirectoryList::VAR_DIR),
63  BP . '/app/etc/',
64  $settings->get('TESTS_MAGENTO_MODE'),
65  AutoloaderRegistry::getAutoloader()
66  );
67 
68  if (defined('TESTS_MAGENTO_INSTALLATION') && TESTS_MAGENTO_INSTALLATION === 'enabled') {
69  $cleanup = (defined('TESTS_CLEANUP') && TESTS_CLEANUP === 'enabled');
70  $application->install($cleanup);
71  }
72 
73  $bootstrap = new \Magento\TestFramework\Bootstrap(
74  $settings,
75  new \Magento\TestFramework\Bootstrap\Environment(),
76  new \Magento\TestFramework\Bootstrap\WebapiDocBlock("{$integrationTestsDir}/testsuite"),
77  new \Magento\TestFramework\Bootstrap\Profiler(new \Magento\Framework\Profiler\Driver\Standard()),
78  $shell,
80  new \Magento\TestFramework\Bootstrap\MemoryFactory($shell)
81  );
82  $bootstrap->runBootstrap();
83  $application->initialize();
84 
85  \Magento\TestFramework\Helper\Bootstrap::setInstance(new \Magento\TestFramework\Helper\Bootstrap($bootstrap));
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  );
98 } catch (\Exception $e) {
99  echo $e . PHP_EOL;
100  exit(1);
101 }
102 
107 {
108  set_error_handler(
109  function ($errNo, $errStr, $errFile, $errLine) {
110  if (error_reporting()) {
111  $errorNames = [
112  E_ERROR => 'Error',
113  E_WARNING => 'Warning',
114  E_PARSE => 'Parse',
115  E_NOTICE => 'Notice',
116  E_CORE_ERROR => 'Core Error',
117  E_CORE_WARNING => 'Core Warning',
118  E_COMPILE_ERROR => 'Compile Error',
119  E_COMPILE_WARNING => 'Compile Warning',
120  E_USER_ERROR => 'User Error',
121  E_USER_WARNING => 'User Warning',
122  E_USER_NOTICE => 'User Notice',
123  E_STRICT => 'Strict',
124  E_RECOVERABLE_ERROR => 'Recoverable Error',
125  E_DEPRECATED => 'Deprecated',
126  E_USER_DEPRECATED => 'User Deprecated',
127  ];
128 
129  $errName = isset($errorNames[$errNo]) ? $errorNames[$errNo] : "";
130 
131  throw new \PHPUnit\Framework\Exception(
132  sprintf("%s: %s in %s:%s.", $errName, $errStr, $errFile, $errLine),
133  $errNo
134  );
135  }
136  }
137  );
138 }
if(!file_exists($installConfigFile)) $dirList
Definition: bootstrap.php:57
$fixtureBaseDir
Definition: bootstrap.php:15
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
$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
$filesystem
$testFrameworkDir
Definition: bootstrap.php:46
$installConfigFile
Definition: bootstrap.php:49