@@ -135,12 +135,17 @@ private function setUpLaunch()
135
135
{
136
136
$ frontName = 'frontName ' ;
137
137
$ areaCode = 'areaCode ' ;
138
- $ this ->requestMock ->expects ($ this ->once ())->method ('getFrontName ' )->will ($ this ->returnValue ($ frontName ));
138
+ $ this ->requestMock ->expects ($ this ->once ())
139
+ ->method ('getFrontName ' )
140
+ ->willReturn ($ frontName );
139
141
$ this ->areaListMock ->expects ($ this ->once ())
140
142
->method ('getCodeByFrontName ' )
141
- ->with ($ frontName )->will ($ this ->returnValue ($ areaCode ));
143
+ ->with ($ frontName )
144
+ ->willReturn ($ areaCode );
142
145
$ this ->configLoaderMock ->expects ($ this ->once ())
143
- ->method ('load ' )->with ($ areaCode )->will ($ this ->returnValue ([]));
146
+ ->method ('load ' )
147
+ ->with ($ areaCode )
148
+ ->willReturn ([]);
144
149
$ this ->objectManagerMock ->expects ($ this ->once ())->method ('configure ' )->with ([]);
145
150
$ this ->objectManagerMock ->expects ($ this ->once ())
146
151
->method ('get ' )
@@ -149,13 +154,15 @@ private function setUpLaunch()
149
154
$ this ->frontControllerMock ->expects ($ this ->once ())
150
155
->method ('dispatch ' )
151
156
->with ($ this ->requestMock )
152
- ->will ($ this ->returnValue ( $ this -> responseMock ) );
157
+ ->willReturn ($ this ->responseMock );
153
158
}
154
159
155
160
public function testLaunchSuccess ()
156
161
{
157
162
$ this ->setUpLaunch ();
158
- $ this ->requestMock ->expects ($ this ->once ())->method ('isHead ' )->will ($ this ->returnValue (false ));
163
+ $ this ->requestMock ->expects ($ this ->once ())
164
+ ->method ('isHead ' )
165
+ ->willReturn (false );
159
166
$ this ->eventManagerMock ->expects ($ this ->once ())
160
167
->method ('dispatch ' )
161
168
->with (
@@ -172,14 +179,16 @@ public function testLaunchSuccess()
172
179
public function testLaunchException ()
173
180
{
174
181
$ this ->setUpLaunch ();
175
- $ this ->frontControllerMock ->expects ($ this ->once ())->method ('dispatch ' )->with ($ this ->requestMock )->will (
176
- $ this ->returnCallback (
177
- function () {
178
- // phpcs:ignore Magento2.Exceptions.DirectThrow
179
- throw new \Exception ('Message ' );
180
- }
181
- )
182
- );
182
+ $ this ->frontControllerMock ->expects ($ this ->once ())
183
+ ->method ('dispatch ' )
184
+ ->with ($ this ->requestMock )->will (
185
+ $ this ->returnCallback (
186
+ function () {
187
+ // phpcs:ignore Magento2.Exceptions.DirectThrow
188
+ throw new \Exception ('Message ' );
189
+ }
190
+ )
191
+ );
183
192
$ this ->http ->launch ();
184
193
}
185
194
@@ -192,20 +201,22 @@ function () {
192
201
public function testLaunchHeadRequest ($ body , $ expectedLength )
193
202
{
194
203
$ this ->setUpLaunch ();
195
- $ this ->requestMock ->expects ($ this ->once ())->method ('isHead ' )->will ($ this ->returnValue (true ));
204
+ $ this ->requestMock ->expects ($ this ->once ())
205
+ ->method ('isHead ' )
206
+ ->willReturn (true );
196
207
$ this ->responseMock ->expects ($ this ->once ())
197
208
->method ('getHttpResponseCode ' )
198
- ->will ( $ this -> returnValue ( 200 ) );
209
+ ->willReturn ( 200 );
199
210
$ this ->responseMock ->expects ($ this ->once ())
200
211
->method ('getContent ' )
201
- ->will ( $ this -> returnValue ( $ body) );
212
+ ->willReturn ( $ body );
202
213
$ this ->responseMock ->expects ($ this ->once ())
203
214
->method ('clearBody ' )
204
- ->will ($ this ->returnValue ( $ this -> responseMock ) );
215
+ ->willReturn ($ this ->responseMock );
205
216
$ this ->responseMock ->expects ($ this ->once ())
206
217
->method ('setHeader ' )
207
218
->with ('Content-Length ' , $ expectedLength )
208
- ->will ($ this ->returnValue ( $ this -> responseMock ) );
219
+ ->willReturn ($ this ->responseMock );
209
220
$ this ->eventManagerMock ->expects ($ this ->once ())
210
221
->method ('dispatch ' )
211
222
->with (
@@ -219,7 +230,7 @@ public function testLaunchHeadRequest($body, $expectedLength)
219
230
* Different test content for responseMock with their expected lengths in bytes.
220
231
* @return array
221
232
*/
222
- public function dataProviderForTestLaunchHeadRequest ()
233
+ public function dataProviderForTestLaunchHeadRequest (): array
223
234
{
224
235
return [
225
236
[
@@ -244,20 +255,29 @@ public function dataProviderForTestLaunchHeadRequest()
244
255
public function testHandleDeveloperModeNotInstalled ()
245
256
{
246
257
$ dir = $ this ->getMockForAbstractClass (\Magento \Framework \Filesystem \Directory \ReadInterface::class);
247
- $ dir ->expects ($ this ->once ())->method ('getAbsolutePath ' )->willReturn (__DIR__ );
258
+ $ dir ->expects ($ this ->once ())
259
+ ->method ('getAbsolutePath ' )
260
+ ->willReturn (__DIR__ );
248
261
$ this ->filesystemMock ->expects ($ this ->once ())
249
262
->method ('getDirectoryRead ' )
250
263
->with (DirectoryList::ROOT )
251
264
->willReturn ($ dir );
252
- $ this ->responseMock ->expects ($ this ->once ())->method ('setRedirect ' )->with ('/_files/ ' );
253
- $ this ->responseMock ->expects ($ this ->once ())->method ('sendHeaders ' );
265
+ $ this ->responseMock ->expects ($ this ->once ())
266
+ ->method ('setRedirect ' )
267
+ ->with ('/_files/ ' );
268
+ $ this ->responseMock ->expects ($ this ->once ())
269
+ ->method ('sendHeaders ' );
254
270
$ bootstrap = $ this ->getBootstrapNotInstalled ();
255
- $ bootstrap ->expects ($ this ->once ())->method ('getParams ' )->willReturn ([
256
- 'SCRIPT_NAME ' => '/index.php ' ,
257
- 'DOCUMENT_ROOT ' => __DIR__ ,
258
- 'SCRIPT_FILENAME ' => __DIR__ . '/index.php ' ,
259
- SetupInfo::PARAM_NOT_INSTALLED_URL_PATH => '_files ' ,
260
- ]);
271
+ $ bootstrap ->expects ($ this ->once ())
272
+ ->method ('getParams ' )
273
+ ->willReturn (
274
+ [
275
+ 'SCRIPT_NAME ' => '/index.php ' ,
276
+ 'DOCUMENT_ROOT ' => __DIR__ ,
277
+ 'SCRIPT_FILENAME ' => __DIR__ . '/index.php ' ,
278
+ SetupInfo::PARAM_NOT_INSTALLED_URL_PATH => '_files ' ,
279
+ ]
280
+ );
261
281
$ this ->assertTrue ($ this ->http ->catchException ($ bootstrap , new \Exception ('Test Message ' )));
262
282
}
263
283
@@ -266,24 +286,37 @@ public function testHandleDeveloperMode()
266
286
$ this ->filesystemMock ->expects ($ this ->once ())
267
287
->method ('getDirectoryRead ' )
268
288
->will ($ this ->throwException (new \Exception ('strange error ' )));
269
- $ this ->responseMock ->expects ($ this ->once ())->method ('setHttpResponseCode ' )->with (500 );
270
- $ this ->responseMock ->expects ($ this ->once ())->method ('setHeader ' )->with ('Content-Type ' , 'text/plain ' );
289
+ $ this ->responseMock ->expects ($ this ->once ())
290
+ ->method ('setHttpResponseCode ' )
291
+ ->with (500 );
292
+ $ this ->responseMock ->expects ($ this ->once ())
293
+ ->method ('setHeader ' )
294
+ ->with ('Content-Type ' , 'text/plain ' );
271
295
$ constraint = new \PHPUnit \Framework \Constraint \StringStartsWith ('1 exception(s): ' );
272
- $ this ->responseMock ->expects ($ this ->once ())->method ('setBody ' )->with ($ constraint );
273
- $ this ->responseMock ->expects ($ this ->once ())->method ('sendResponse ' );
296
+ $ this ->responseMock ->expects ($ this ->once ())
297
+ ->method ('setBody ' )
298
+ ->with ($ constraint );
299
+ $ this ->responseMock ->expects ($ this ->once ())
300
+ ->method ('sendResponse ' );
274
301
$ bootstrap = $ this ->getBootstrapNotInstalled ();
275
- $ bootstrap ->expects ($ this ->once ())->method ('getParams ' )->willReturn (
276
- ['DOCUMENT_ROOT ' => 'something ' , 'SCRIPT_FILENAME ' => 'something/else ' ]
277
- );
302
+ $ bootstrap ->expects ($ this ->once ())
303
+ ->method ('getParams ' )
304
+ ->willReturn (
305
+ ['DOCUMENT_ROOT ' => 'something ' , 'SCRIPT_FILENAME ' => 'something/else ' ]
306
+ );
278
307
$ this ->assertTrue ($ this ->http ->catchException ($ bootstrap , new \Exception ('Test ' )));
279
308
}
280
309
281
310
public function testCatchExceptionSessionException ()
282
311
{
283
- $ this ->responseMock ->expects ($ this ->once ())->method ('setRedirect ' );
284
- $ this ->responseMock ->expects ($ this ->once ())->method ('sendHeaders ' );
312
+ $ this ->responseMock ->expects ($ this ->once ())
313
+ ->method ('setRedirect ' );
314
+ $ this ->responseMock ->expects ($ this ->once ())
315
+ ->method ('sendHeaders ' );
285
316
$ bootstrap = $ this ->createMock (\Magento \Framework \App \Bootstrap::class);
286
- $ bootstrap ->expects ($ this ->once ())->method ('isDeveloperMode ' )->willReturn (false );
317
+ $ bootstrap ->expects ($ this ->once ())
318
+ ->method ('isDeveloperMode ' )
319
+ ->willReturn (false );
287
320
$ this ->assertTrue ($ this ->http ->catchException (
288
321
$ bootstrap ,
289
322
new \Magento \Framework \Exception \SessionException (new \Magento \Framework \Phrase ('Test ' ))
@@ -298,8 +331,12 @@ public function testCatchExceptionSessionException()
298
331
private function getBootstrapNotInstalled ()
299
332
{
300
333
$ bootstrap = $ this ->createMock (\Magento \Framework \App \Bootstrap::class);
301
- $ bootstrap ->expects ($ this ->once ())->method ('isDeveloperMode ' )->willReturn (true );
302
- $ bootstrap ->expects ($ this ->once ())->method ('getErrorCode ' )->willReturn (Bootstrap::ERR_IS_INSTALLED );
334
+ $ bootstrap ->expects ($ this ->once ())
335
+ ->method ('isDeveloperMode ' )
336
+ ->willReturn (true );
337
+ $ bootstrap ->expects ($ this ->once ())
338
+ ->method ('getErrorCode ' )
339
+ ->willReturn (Bootstrap::ERR_IS_INSTALLED );
303
340
return $ bootstrap ;
304
341
}
305
342
}
0 commit comments