1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Bootstrap for the integration testing environment
*/
namespace Magento\TestFramework;
class Bootstrap
{
/**#@+
* Predefined admin user credentials
*/
const ADMIN_NAME = 'user';
const ADMIN_PASSWORD = 'password1';
const ADMIN_EMAIL = 'admin@example.com';
const ADMIN_FIRSTNAME = 'firstname';
const ADMIN_LASTNAME = 'lastname';
/**#@- */
/**
* Predefined admin user role name
*/
const ADMIN_ROLE_NAME = 'Administrators';
/**
* @var \Magento\TestFramework\Bootstrap\Settings
*/
private $_settings;
/**
* @var \Magento\TestFramework\Application
*/
private $_application;
/**
* @var \Magento\TestFramework\Bootstrap\Environment
*/
private $_envBootstrap;
/**
* @var \Magento\TestFramework\Bootstrap\DocBlock
*/
private $_docBlockBootstrap;
/**
* @var \Magento\TestFramework\Bootstrap\Profiler
*/
private $_profilerBootstrap;
/**
* @var \Magento\Framework\Shell
*/
private $_shell;
/**
* @var \Magento\TestFramework\Bootstrap\MemoryFactory
*/
private $memoryFactory;
/**
* Constructor
*
* @param \Magento\TestFramework\Bootstrap\Settings $settings
* @param \Magento\TestFramework\Bootstrap\Environment $envBootstrap
* @param \Magento\TestFramework\Bootstrap\DocBlock $docBlockBootstrap
* @param \Magento\TestFramework\Bootstrap\Profiler $profilerBootstrap
* @param \Magento\Framework\Shell $shell
* @param Application $application
* @param Bootstrap\MemoryFactory $memoryFactory
* @internal param string $tmpDir
*/
public function __construct(
\Magento\TestFramework\Bootstrap\Settings $settings,
\Magento\TestFramework\Bootstrap\Environment $envBootstrap,
\Magento\TestFramework\Bootstrap\DocBlock $docBlockBootstrap,
\Magento\TestFramework\Bootstrap\Profiler $profilerBootstrap,
\Magento\Framework\Shell $shell,
\Magento\TestFramework\Application $application,
\Magento\TestFramework\Bootstrap\MemoryFactory $memoryFactory
) {
$this->_settings = $settings;
$this->_envBootstrap = $envBootstrap;
$this->_docBlockBootstrap = $docBlockBootstrap;
$this->_profilerBootstrap = $profilerBootstrap;
$this->_shell = $shell;
$this->_application = $application;
$this->memoryFactory = $memoryFactory;
}
/**
* Retrieve the application instance
*
* @return Application
*/
public function getApplication()
{
return $this->_application;
}
/**
* 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);
}
}