5
5
*/
6
6
namespace Magento \TestFramework ;
7
7
8
- use Magento \Framework \Autoload \AutoloaderInterface ;
9
- use Magento \Framework \App \Filesystem \DirectoryList ;
10
8
use Magento \Framework \App \DeploymentConfig ;
11
- use Magento \Framework \Config \ConfigOptionsListConstants ;
12
9
use Magento \Framework \App \DeploymentConfig \Reader ;
10
+ use Magento \Framework \App \Filesystem \DirectoryList ;
11
+ use Magento \Framework \Autoload \AutoloaderInterface ;
12
+ use Magento \Framework \Config \ConfigOptionsListConstants ;
13
13
use Magento \Framework \Filesystem \Glob ;
14
+ use Magento \Framework \Mail ;
15
+ use Magento \TestFramework ;
16
+ use Psr \Log \LoggerInterface ;
14
17
15
18
/**
16
19
* Encapsulates application installation, initialization and uninstall.
@@ -28,7 +31,7 @@ class Application
28
31
/**
29
32
* DB vendor adapter instance.
30
33
*
31
- * @var \Magento\ TestFramework\Db\AbstractDb
34
+ * @var TestFramework\Db\AbstractDb
32
35
*/
33
36
protected $ _db ;
34
37
@@ -105,14 +108,14 @@ class Application
105
108
/**
106
109
* Object manager factory.
107
110
*
108
- * @var \Magento\ TestFramework\ObjectManagerFactory
111
+ * @var TestFramework\ObjectManagerFactory
109
112
*/
110
113
protected $ _factory ;
111
114
112
115
/**
113
116
* Directory list.
114
117
*
115
- * @var \Magento\Framework\App\Filesystem\ DirectoryList
118
+ * @var DirectoryList
116
119
*/
117
120
protected $ dirList ;
118
121
@@ -180,7 +183,7 @@ public function __construct(
180
183
$ this ->loadTestExtensionAttributes = $ loadTestExtensionAttributes ;
181
184
182
185
$ customDirs = $ this ->getCustomDirs ();
183
- $ this ->dirList = new \ Magento \ Framework \ App \ Filesystem \ DirectoryList (BP , $ customDirs );
186
+ $ this ->dirList = new DirectoryList (BP , $ customDirs );
184
187
\Magento \Framework \Autoload \Populator::populateMappings (
185
188
$ autoloadWrapper ,
186
189
$ this ->dirList
@@ -189,9 +192,9 @@ public function __construct(
189
192
\Magento \Framework \App \Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => $ customDirs ,
190
193
\Magento \Framework \App \State::PARAM_MODE => $ appMode
191
194
];
192
- $ driverPool = new \Magento \Framework \Filesystem \DriverPool ;
193
- $ configFilePool = new \Magento \Framework \Config \File \ConfigFilePool ;
194
- $ this ->_factory = new \ Magento \ TestFramework \ObjectManagerFactory ($ this ->dirList , $ driverPool , $ configFilePool );
195
+ $ driverPool = new \Magento \Framework \Filesystem \DriverPool () ;
196
+ $ configFilePool = new \Magento \Framework \Config \File \ConfigFilePool () ;
197
+ $ this ->_factory = new TestFramework \ObjectManagerFactory ($ this ->dirList , $ driverPool , $ configFilePool );
195
198
196
199
$ this ->_configDir = $ this ->dirList ->getPath (DirectoryList::CONFIG );
197
200
$ this ->globalConfigFile = $ globalConfigFile ;
@@ -200,7 +203,7 @@ public function __construct(
200
203
/**
201
204
* Retrieve the database adapter instance.
202
205
*
203
- * @return \Magento\ TestFramework\Db\AbstractDb
206
+ * @return TestFramework\Db\AbstractDb
204
207
*/
205
208
public function getDbInstance ()
206
209
{
@@ -310,7 +313,7 @@ private function initLogger()
310
313
$ objectManager = Helper \Bootstrap::getObjectManager ();
311
314
/** @var \Psr\Log\LoggerInterface $logger */
312
315
$ logger = $ objectManager ->create (
313
- \ Magento \ TestFramework \ErrorLog \Logger::class,
316
+ TestFramework \ErrorLog \Logger::class,
314
317
[
315
318
'name ' => 'integration-tests ' ,
316
319
'handlers ' => [
@@ -331,9 +334,8 @@ private function initLogger()
331
334
]
332
335
]
333
336
);
334
-
335
- $ objectManager ->removeSharedInstance (\Magento \Framework \Logger \Monolog::class);
336
- $ objectManager ->addSharedInstance ($ logger , \Magento \Framework \Logger \Monolog::class);
337
+ $ objectManager ->removeSharedInstance (LoggerInterface::class, true );
338
+ $ objectManager ->addSharedInstance ($ logger , LoggerInterface::class, true );
337
339
return $ logger ;
338
340
}
339
341
@@ -351,31 +353,35 @@ public function initialize($overriddenParams = [])
351
353
? $ overriddenParams [\Magento \Framework \App \Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS ]
352
354
: [];
353
355
$ directoryList = new DirectoryList (BP , $ directories );
354
- /** @var \Magento\ TestFramework\ObjectManager $objectManager */
356
+ /** @var TestFramework\ObjectManager $objectManager */
355
357
$ objectManager = Helper \Bootstrap::getObjectManager ();
356
358
if (!$ objectManager ) {
357
359
$ objectManager = $ this ->_factory ->create ($ overriddenParams );
358
- $ objectManager ->addSharedInstance ($ directoryList , \Magento \Framework \App \Filesystem \DirectoryList::class);
359
- $ objectManager ->addSharedInstance ($ directoryList , \Magento \Framework \Filesystem \DirectoryList::class);
360
+ $ objectManager ->addSharedInstance (
361
+ $ directoryList ,
362
+ DirectoryList::class
363
+ );
364
+ $ objectManager ->addSharedInstance (
365
+ $ directoryList ,
366
+ \Magento \Framework \Filesystem \DirectoryList::class
367
+ );
360
368
} else {
361
369
$ objectManager = $ this ->_factory ->restore ($ objectManager , $ directoryList , $ overriddenParams );
362
370
}
363
- /** @var \Magento\ TestFramework\App\Filesystem $filesystem */
364
- $ filesystem = $ objectManager ->get (\ Magento \ TestFramework \App \Filesystem::class);
371
+ /** @var TestFramework\App\Filesystem $filesystem */
372
+ $ filesystem = $ objectManager ->get (TestFramework \App \Filesystem::class);
365
373
$ objectManager ->removeSharedInstance (\Magento \Framework \Filesystem::class);
366
374
$ objectManager ->addSharedInstance ($ filesystem , \Magento \Framework \Filesystem::class);
367
375
Helper \Bootstrap::setObjectManager ($ objectManager );
368
376
$ this ->initLogger ();
369
- $ sequenceBuilder = $ objectManager ->get (\ Magento \ TestFramework \Db \Sequence \Builder::class);
377
+ $ sequenceBuilder = $ objectManager ->get (TestFramework \Db \Sequence \Builder::class);
370
378
$ objectManager ->addSharedInstance ($ sequenceBuilder , \Magento \SalesSequence \Model \Builder::class);
371
379
372
380
$ objectManagerConfiguration = [
373
381
'preferences ' => [
374
- \Magento \Framework \App \State::class => \Magento \TestFramework \App \State::class,
375
- \Magento \Framework \Mail \TransportInterface::class =>
376
- \Magento \TestFramework \Mail \TransportInterfaceMock::class,
377
- \Magento \Framework \Mail \Template \TransportBuilder::class
378
- => \Magento \TestFramework \Mail \Template \TransportBuilderMock::class,
382
+ \Magento \Framework \App \State::class => TestFramework \App \State::class,
383
+ Mail \TransportInterface::class => TestFramework \Mail \TransportInterfaceMock::class,
384
+ Mail \Template \TransportBuilder::class => TestFramework \Mail \Template \TransportBuilderMock::class,
379
385
]
380
386
];
381
387
if ($ this ->loadTestExtensionAttributes ) {
@@ -385,7 +391,7 @@ public function initialize($overriddenParams = [])
385
391
\Magento \Framework \Api \ExtensionAttribute \Config \Reader::class => [
386
392
'arguments ' => [
387
393
'fileResolver ' => [
388
- 'instance ' => \ Magento \ TestFramework \Api \Config \Reader \FileResolver::class
394
+ 'instance ' => TestFramework \Api \Config \Reader \FileResolver::class
389
395
],
390
396
],
391
397
],
@@ -400,26 +406,26 @@ public function initialize($overriddenParams = [])
400
406
[
401
407
'core_app_init_current_store_after ' => [
402
408
'integration_tests ' => [
403
- 'instance ' => \ Magento \ TestFramework \Event \Magento::class,
409
+ 'instance ' => TestFramework \Event \Magento::class,
404
410
'name ' => 'integration_tests '
405
411
]
406
412
]
407
413
]
408
414
);
409
415
410
416
if ($ this ->canLoadArea ) {
411
- $ this ->loadArea (\ Magento \ TestFramework \Application::DEFAULT_APP_AREA );
417
+ $ this ->loadArea (TestFramework \Application::DEFAULT_APP_AREA );
412
418
}
413
419
414
- \ Magento \ TestFramework \Helper \Bootstrap::getObjectManager ()->configure (
420
+ TestFramework \Helper \Bootstrap::getObjectManager ()->configure (
415
421
$ objectManager ->get (\Magento \Framework \ObjectManager \DynamicConfigInterface::class)->getConfiguration ()
416
422
);
417
423
\Magento \Framework \Phrase::setRenderer (
418
424
$ objectManager ->get (\Magento \Framework \Phrase \Renderer \Placeholder::class)
419
425
);
420
426
421
427
if ($ this ->canInstallSequence ) {
422
- /** @var \Magento\ TestFramework\Db\Sequence $sequence */
428
+ /** @var TestFramework\Db\Sequence $sequence */
423
429
$ sequence = $ objectManager ->get (\Magento \TestFramework \Db \Sequence::class);
424
430
$ sequence ->generateSequences ();
425
431
}
@@ -649,7 +655,7 @@ protected function _ensureDirExists($dir)
649
655
// phpcs:ignore Magento2.Functions.DiscouragedFunction
650
656
mkdir ($ dir , 0777 , true );
651
657
umask ($ old );
652
- // phpcs:ignore Magento2.Functions.DiscouragedFunction
658
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
653
659
} elseif (!is_dir ($ dir )) {
654
660
throw new \Magento \Framework \Exception \LocalizedException (__ ("'%1' is not a directory. " , $ dir ));
655
661
}
0 commit comments