Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
BootstrapTest Class Reference
Inheritance diagram for BootstrapTest:

Public Member Functions

 testGetApplication ()
 
 testRunBootstrap ()
 
 testRunBootstrapProfilerEnabled ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Protected Attributes

 $_object
 
 $_requiredSettings
 
 $_settings
 
 $_envBootstrap
 
 $_docBlockBootstrap
 
 $_profilerBootstrap
 
 $memoryFactory
 
 $_shell
 
 $_integrationTestsDir
 

Detailed Description

Definition at line 12 of file BootstrapTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 68 of file BootstrapTest.php.

69  {
70  $this->_integrationTestsDir = realpath(__DIR__ . '/../../../../../../');
71  $this->_settings = $this->createMock(\Magento\TestFramework\Bootstrap\Settings::class);
72  $this->_envBootstrap = $this->createPartialMock(
73  \Magento\TestFramework\Bootstrap\Environment::class,
74  ['emulateHttpRequest', 'emulateSession']
75  );
76  $this->_docBlockBootstrap = $this->getMockBuilder(\Magento\TestFramework\Bootstrap\DocBlock::class)
77  ->setMethods(['registerAnnotations'])
78  ->setConstructorArgs([__DIR__])
79  ->getMock();
80  $profilerDriver =
81  $this->createPartialMock(\Magento\Framework\Profiler\Driver\Standard::class, ['registerOutput']);
82  $this->_profilerBootstrap = $this->getMockBuilder(\Magento\TestFramework\Bootstrap\Profiler::class)
83  ->setMethods(['registerFileProfiler', 'registerBambooProfiler'])
84  ->setConstructorArgs([$profilerDriver])
85  ->getMock();
86 
87  $this->_shell = $this->createPartialMock(\Magento\Framework\Shell::class, ['execute']);
88  $this->application = $this->createMock(\Magento\TestFramework\Application::class);
89  $this->memoryFactory = $this->createMock(\Magento\TestFramework\Bootstrap\MemoryFactory::class);
90  $this->_object = new \Magento\TestFramework\Bootstrap(
91  $this->_settings,
92  $this->_envBootstrap,
93  $this->_docBlockBootstrap,
94  $this->_profilerBootstrap,
95  $this->_shell,
96  $this->application,
97  $this->memoryFactory
98  );
99  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

◆ tearDown()

tearDown ( )
protected

Definition at line 101 of file BootstrapTest.php.

102  {
103  $this->_object = null;
104  $this->_settings = null;
105  $this->_envBootstrap = null;
106  $this->_docBlockBootstrap = null;
107  $this->_profilerBootstrap = null;
108  $this->_memoryBootstrap = null;
109  $this->_shell = null;
110  }

◆ testGetApplication()

testGetApplication ( )

Definition at line 112 of file BootstrapTest.php.

113  {
114  $this->assertSame($this->application, $this->_object->getApplication());
115  }

◆ testRunBootstrap()

testRunBootstrap ( )

Definition at line 117 of file BootstrapTest.php.

118  {
119  $this->_envBootstrap->expects($this->once())
120  ->method('emulateHttpRequest')
121  ->with($this->identicalTo($_SERVER));
122  $this->_envBootstrap->expects($this->once())
123  ->method('emulateSession')
124  ->with($this->identicalTo(isset($_SESSION) ? $_SESSION : null));
125 
126  $memUsageLimit = '100B';
127  $memLeakLimit = '60B';
128  $settingsMap = [
129  ['TESTS_MEM_USAGE_LIMIT', 0, $memUsageLimit],
130  ['TESTS_MEM_LEAK_LIMIT', 0, $memLeakLimit],
131  ];
132  $this->_settings->expects($this->any())
133  ->method('get')
134  ->will($this->returnValueMap($settingsMap));
135  $memoryBootstrap = $this->createPartialMock(
136  \Magento\TestFramework\Bootstrap\Memory::class,
137  ['activateStatsDisplaying', 'activateLimitValidation']
138  );
139  $memoryBootstrap->expects($this->once())->method('activateStatsDisplaying');
140  $memoryBootstrap->expects($this->once())->method('activateLimitValidation');
141  $this->memoryFactory->expects($this->once())
142  ->method('create')
143  ->with($memUsageLimit, $memLeakLimit)
144  ->will($this->returnValue($memoryBootstrap));
145 
146  $this->_docBlockBootstrap->expects($this->once())
147  ->method('registerAnnotations')
148  ->with($this->isInstanceOf(\Magento\TestFramework\Application::class));
149 
150  $this->_profilerBootstrap->expects($this->never())->method($this->anything());
151 
152  $this->_object->runBootstrap();
153  }

◆ testRunBootstrapProfilerEnabled()

testRunBootstrapProfilerEnabled ( )

Definition at line 155 of file BootstrapTest.php.

156  {
157  $memoryBootstrap = $this->createPartialMock(
158  \Magento\TestFramework\Bootstrap\Memory::class,
159  ['activateStatsDisplaying', 'activateLimitValidation']
160  );
161  $memoryBootstrap->expects($this->once())->method('activateStatsDisplaying');
162  $memoryBootstrap->expects($this->once())->method('activateLimitValidation');
163  $this->memoryFactory->expects($this->once())
164  ->method('create')
165  ->with(0, 0)
166  ->will($this->returnValue($memoryBootstrap));
167 
168  $settingsMap = [
169  ['TESTS_PROFILER_FILE', '', 'profiler.csv'],
170  ['TESTS_BAMBOO_PROFILER_FILE', '', 'profiler_bamboo.csv'],
171  ['TESTS_BAMBOO_PROFILER_METRICS_FILE', '', 'profiler_metrics.php'],
172  ];
173  $this->_settings->expects($this->any())
174  ->method('getAsFile')
175  ->will($this->returnValueMap($settingsMap));
176  $this->_profilerBootstrap
177  ->expects($this->once())
178  ->method('registerFileProfiler')
179  ->with("profiler.csv");
180  $this->_profilerBootstrap
181  ->expects($this->once())
182  ->method('registerBambooProfiler')
183  ->with("profiler_bamboo.csv", "profiler_metrics.php");
184  $this->_object->runBootstrap();
185  }

Field Documentation

◆ $_docBlockBootstrap

$_docBlockBootstrap
protected

Definition at line 41 of file BootstrapTest.php.

◆ $_envBootstrap

$_envBootstrap
protected

Definition at line 36 of file BootstrapTest.php.

◆ $_integrationTestsDir

$_integrationTestsDir
protected

Definition at line 66 of file BootstrapTest.php.

◆ $_object

$_object
protected

Definition at line 17 of file BootstrapTest.php.

◆ $_profilerBootstrap

$_profilerBootstrap
protected

Definition at line 46 of file BootstrapTest.php.

◆ $_requiredSettings

$_requiredSettings
protected
Initial value:
= [
'TESTS_INSTALL_CONFIG_FILE' => 'etc/install-config-mysql.php',
]

Definition at line 24 of file BootstrapTest.php.

◆ $_settings

$_settings
protected

Definition at line 31 of file BootstrapTest.php.

◆ $_shell

$_shell
protected

Definition at line 56 of file BootstrapTest.php.

◆ $memoryFactory

$memoryFactory
protected

Definition at line 51 of file BootstrapTest.php.


The documentation for this class was generated from the following file: