Skip to content

Commit c929d3c

Browse files
33308: Code refactoring
1 parent 83e1cda commit c929d3c

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

dev/tests/unit/Magento/FunctionalTestFramework/Util/ModuleResolverTest.php

+19-11
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ protected function setUp(): void
3737
public static function tearDownAfterClass(): void
3838
{
3939
TestLoggingUtil::getInstance()->clearMockLoggingUtil();
40+
41+
$moduleResolverServiceInstance = new ReflectionProperty(ModuleResolverService::class, 'INSTANCE');
42+
$moduleResolverServiceInstance->setAccessible(true);
43+
$moduleResolverServiceInstance->setValue(null);
44+
45+
$mftfAppConfigInstance = new ReflectionProperty(MftfApplicationConfig::class, 'MFTF_APPLICATION_CONTEXT');
46+
$mftfAppConfigInstance->setAccessible(true);
47+
$mftfAppConfigInstance->setValue(null);
4048
}
4149

4250
/**
@@ -48,8 +56,8 @@ public static function tearDownAfterClass(): void
4856
public function testGetModulePathsAlreadySet(): void
4957
{
5058
$resolver = ModuleResolver::getInstance();
51-
$this->setMockResolverProperties($resolver, ["example" . DIRECTORY_SEPARATOR . "paths"]);
52-
$this->assertEquals(["example" . DIRECTORY_SEPARATOR . "paths"], $resolver->getModulesPath());
59+
$this->setMockResolverProperties($resolver, ['example' . DIRECTORY_SEPARATOR . 'paths']);
60+
$this->assertEquals(['example' . DIRECTORY_SEPARATOR . 'paths'], $resolver->getModulesPath());
5361
}
5462

5563
/**
@@ -68,15 +76,15 @@ public function testGetModulePathsAggregate(): void
6876
->willReturn(
6977
[
7078
'Magento_example' => 'some' . DIRECTORY_SEPARATOR . 'path' . DIRECTORY_SEPARATOR . 'example',
71-
'Magento_sample' => 'other' . DIRECTORY_SEPARATOR . 'path' . DIRECTORY_SEPARATOR . 'sample',
79+
'Magento_sample' => 'other' . DIRECTORY_SEPARATOR . 'path' . DIRECTORY_SEPARATOR . 'sample'
7280
]
7381
);
7482
$moduleResolverService->expects($this->any())
7583
->method('aggregateTestModulePaths')
7684
->willReturn(
7785
[
7886
'some' . DIRECTORY_SEPARATOR . 'path' . DIRECTORY_SEPARATOR . 'example' => ['example'],
79-
'other' . DIRECTORY_SEPARATOR . 'path' . DIRECTORY_SEPARATOR . 'sample' => ['sample'],
87+
'other' . DIRECTORY_SEPARATOR . 'path' . DIRECTORY_SEPARATOR . 'sample' => ['sample']
8088
]
8189
);
8290

@@ -116,7 +124,7 @@ public function testAggregateTestModulePathsFromComposerJson(): void
116124
[
117125
'Magento_ModuleB',
118126
'Magento_ModuleC'
119-
],
127+
]
120128
]
121129
);
122130

@@ -154,7 +162,7 @@ public function testAggregateTestModulePathsFromComposerInstaller(): void
154162
[
155163
'Magento_ModuleB',
156164
'Magento_ModuleC'
157-
],
165+
]
158166
]
159167
);
160168

@@ -243,7 +251,7 @@ public function testMergeFlipAndFilterModulePathsNoForceGenerate(): void
243251
4 => 'Magento_ModuleB',
244252
5 => 'Magento_ModuleD',
245253
6 => 'Magento_Otherexample',
246-
7 => 'Magento_ModuleC',
254+
7 => 'Magento_ModuleC'
247255
]
248256
);
249257
$this->assertEquals(
@@ -254,7 +262,7 @@ public function testMergeFlipAndFilterModulePathsNoForceGenerate(): void
254262
'some' . DIRECTORY_SEPARATOR . 'path' . DIRECTORY_SEPARATOR . 'example',
255263
'composer' . DIRECTORY_SEPARATOR . 'json' . DIRECTORY_SEPARATOR . 'pathB',
256264
'composer' . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . 'pathD',
257-
'composer' . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . 'pathC',
265+
'composer' . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . 'pathC'
258266

259267
],
260268
$resolver->getModulesPath()
@@ -284,7 +292,7 @@ public function testMergeFlipNoSortModulePathsNoForceGenerate(): void
284292
. 'Magento' . DIRECTORY_SEPARATOR . 'ModuleBC' =>
285293
[
286294
'Magento_ModuleB',
287-
'Magento_ModuleC',
295+
'Magento_ModuleC'
288296
]
289297
]
290298
);
@@ -363,7 +371,7 @@ public function testMergeFlipAndSortModulePathsForceGenerate(): void
363371
. 'Magento' . DIRECTORY_SEPARATOR . 'ModuleBC' =>
364372
[
365373
'Magento_ModuleB',
366-
'Magento_ModuleC',
374+
'Magento_ModuleC'
367375
]
368376
]
369377
);
@@ -670,7 +678,7 @@ protected function tearDown(): void
670678
{
671679
// re set env
672680
if (!isset($_ENV['MAGENTO_ADMIN_USERNAME'])) {
673-
$_ENV['MAGENTO_ADMIN_USERNAME'] = "admin";
681+
$_ENV['MAGENTO_ADMIN_USERNAME'] = 'admin';
674682
}
675683
}
676684
}

src/Magento/FunctionalTestingFramework/Util/ModuleResolver/ModuleResolverService.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private function __construct()
5353
public static function getInstance()
5454
{
5555
if (self::$INSTANCE === null) {
56-
return new self();
56+
self::$INSTANCE = new ModuleResolverService();
5757
}
5858

5959
return self::$INSTANCE;

0 commit comments

Comments
 (0)