@@ -56,22 +56,29 @@ public function testGetModulePathsAlreadySet()
56
56
*/
57
57
public function testGetModulePathsAggregate ()
58
58
{
59
+
59
60
$ this ->mockForceGenerate (false );
60
61
$ this ->setMockResolverClass (
61
62
false ,
62
63
null ,
63
64
null ,
64
65
null ,
65
- ["Magento_example " => "example " . DIRECTORY_SEPARATOR . "paths " ]
66
+ [
67
+ 'some ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'example ' => ['example ' ],
68
+ 'other ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'sample ' => ['sample ' ],
69
+ ],
70
+ null ,
71
+ [
72
+ 'Magento_example ' => 'some ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'example ' ,
73
+ 'Magento_sample ' => 'other ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'sample ' ,
74
+ ]
66
75
);
67
76
$ resolver = ModuleResolver::getInstance ();
68
- $ this ->setMockResolverProperties ($ resolver , null , [0 => " Magento_example " ]);
77
+ $ this ->setMockResolverProperties ($ resolver , null , [0 => ' Magento_example ' , 1 => ' Magento_sample ' ]);
69
78
$ this ->assertEquals (
70
79
[
71
- "example " . DIRECTORY_SEPARATOR . "paths " ,
72
- "example " . DIRECTORY_SEPARATOR . "paths " ,
73
- "example " . DIRECTORY_SEPARATOR . "paths " ,
74
- "example " . DIRECTORY_SEPARATOR . "paths "
80
+ 'some ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'example ' ,
81
+ 'other ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'sample '
75
82
],
76
83
$ resolver ->getModulesPath ()
77
84
);
@@ -91,20 +98,28 @@ public function testGetModulePathsLocations()
91
98
$ this ->mockForceGenerate (false );
92
99
$ mockResolver = $ this ->setMockResolverClass (
93
100
true ,
94
- [0 => " example " ],
101
+ [],
95
102
null ,
96
103
null ,
97
- ["example " => "example " . DIRECTORY_SEPARATOR . "paths " ]
104
+ [],
105
+ [],
106
+ [],
107
+ [],
108
+ [],
109
+ [],
110
+ [],
111
+ null ,
112
+ function ($ arg ) {
113
+ return $ arg ;
114
+ },
115
+ function ($ arg ) {
116
+ return $ arg ;
117
+ }
98
118
);
99
119
$ resolver = ModuleResolver::getInstance ();
100
120
$ this ->setMockResolverProperties ($ resolver , null , null );
101
121
$ this ->assertEquals (
102
- [
103
- "example " . DIRECTORY_SEPARATOR . "paths " ,
104
- "example " . DIRECTORY_SEPARATOR . "paths " ,
105
- "example " . DIRECTORY_SEPARATOR . "paths " ,
106
- "example " . DIRECTORY_SEPARATOR . "paths "
107
- ],
122
+ [],
108
123
$ resolver ->getModulesPath ()
109
124
);
110
125
@@ -114,8 +129,6 @@ public function testGetModulePathsLocations()
114
129
// Define the Module paths from default TESTS_MODULE_PATH
115
130
$ modulePath = defined ('TESTS_MODULE_PATH ' ) ? TESTS_MODULE_PATH : TESTS_BP ;
116
131
117
-
118
-
119
132
$ mockResolver ->verifyInvoked ('globRelevantPaths ' , [$ modulePath , '' ]);
120
133
$ mockResolver ->verifyInvoked (
121
134
'globRelevantPaths ' ,
@@ -150,14 +163,21 @@ public function testGetModulePathsLocations()
150
163
*/
151
164
public function testGetCustomModulePath ()
152
165
{
153
- $ this ->setMockResolverClass (false , ["Magento_TestModule " ], null , null , [], ['otherPath ' ]);
166
+ $ this ->setMockResolverClass (
167
+ false ,
168
+ null ,
169
+ null ,
170
+ null ,
171
+ [],
172
+ ['Magento_Module ' => 'otherPath ' ]
173
+ );
154
174
$ resolver = ModuleResolver::getInstance ();
155
175
$ this ->setMockResolverProperties ($ resolver , null , null , null );
156
176
$ this ->assertEquals (['otherPath ' ], $ resolver ->getModulesPath ());
157
177
TestLoggingUtil::getInstance ()->validateMockLogStatement (
158
178
'info ' ,
159
179
'including custom module ' ,
160
- ['module ' => 'otherPath ' ]
180
+ ['Magento_Module ' => 'otherPath ' ]
161
181
);
162
182
}
163
183
@@ -172,25 +192,36 @@ public function testGetModulePathsBlacklist()
172
192
null ,
173
193
null ,
174
194
null ,
175
- function ($ arg1 , $ arg2 ) {
176
- if ($ arg2 === "" ) {
177
- $ mockValue = ["somePath " => "somePath " ];
178
- } else {
179
- $ mockValue = ["lastPath " => "lastPath " ];
180
- }
181
- return $ mockValue ;
195
+ [],
196
+ [],
197
+ [],
198
+ [],
199
+ [],
200
+ [],
201
+ [],
202
+ [
203
+ "vendor " => "vendor " ,
204
+ "appCode " => "appCode " ,
205
+ "devTests " => "devTests " ,
206
+ "thisPath " => "thisPath "
207
+ ],
208
+ function ($ arg ) {
209
+ return $ arg ;
210
+ },
211
+ function ($ arg ) {
212
+ return $ arg ;
182
213
}
183
214
);
184
215
$ resolver = ModuleResolver::getInstance ();
185
- $ this ->setMockResolverProperties ($ resolver , null , null , ["somePath " ]);
216
+ $ this ->setMockResolverProperties ($ resolver , null , null , ["devTests " => " devTests " ]);
186
217
$ this ->assertEquals (
187
- ["lastPath " , "lastPath " ],
218
+ ["vendor " , "appCode " , " thisPath " ],
188
219
$ resolver ->getModulesPath ()
189
220
);
190
221
TestLoggingUtil::getInstance ()->validateMockLogStatement (
191
222
'info ' ,
192
223
'excluding module ' ,
193
- ['module ' => 'somePath ' ]
224
+ ['module ' => 'devTests ' ]
194
225
);
195
226
}
196
227
@@ -278,6 +309,14 @@ public function testGetAdminTokenWithBadResponse()
278
309
* @param string[] $mockGlob
279
310
* @param string[] $mockRelativePaths
280
311
* @param string[] $mockCustomModules
312
+ * @param string[] $mockGetRegisteredModuleList
313
+ * @param string[] $mockAggregateTestModulePathsFromComposerJson
314
+ * @param string[] $mockAggregateTestModulePathsFromComposerInstaller
315
+ * @param string[] $mockGetComposerJsonTestModulePaths
316
+ * @param string[] $mockGetComposerInstalledTestModulePaths
317
+ * @param string[] $mockAggregateTestModulePaths
318
+ * @param string[] $mockNormalizeModuleNames
319
+ * @param string[] $mockFlipAndFilterModulePathsArray
281
320
* @throws \Exception
282
321
* @return Verifier ModuleResolver double
283
322
*/
@@ -287,7 +326,15 @@ private function setMockResolverClass(
287
326
$ mockCustomMethods = null ,
288
327
$ mockGlob = null ,
289
328
$ mockRelativePaths = null ,
290
- $ mockCustomModules = null
329
+ $ mockCustomModules = null ,
330
+ $ mockGetRegisteredModuleList = null ,
331
+ $ mockAggregateTestModulePathsFromComposerJson = [],
332
+ $ mockAggregateTestModulePathsFromComposerInstaller = [],
333
+ $ mockGetComposerJsonTestModulePaths = [],
334
+ $ mockGetComposerInstalledTestModulePaths = [],
335
+ $ mockAggregateTestModulePaths = null ,
336
+ $ mockNormalizeModuleNames = null ,
337
+ $ mockFlipAndFilterModulePathsArray = null
291
338
) {
292
339
$ property = new \ReflectionProperty (ModuleResolver::class, 'instance ' );
293
340
$ property ->setAccessible (true );
@@ -312,7 +359,23 @@ private function setMockResolverClass(
312
359
if (isset ($ mockCustomModules )) {
313
360
$ mockMethods ['getCustomModulePaths ' ] = $ mockCustomModules ;
314
361
}
315
- // $mockMethods['printMagentoVersionInfo'] = null;
362
+ if (isset ($ mockGetRegisteredModuleList )) {
363
+ $ mockMethods ['getRegisteredModuleList ' ] = $ mockGetRegisteredModuleList ;
364
+ }
365
+ $ mockMethods ['aggregateTestModulePathsFromComposerJson ' ] = $ mockAggregateTestModulePathsFromComposerJson ?? [];
366
+ $ mockMethods ['aggregateTestModulePathsFromComposerInstaller ' ] =
367
+ $ mockAggregateTestModulePathsFromComposerInstaller ?? [];
368
+ $ mockMethods ['getComposerJsonTestModulePaths ' ] = $ mockGetComposerJsonTestModulePaths ?? [];
369
+ $ mockMethods ['getComposerInstalledTestModulePaths ' ] = $ mockGetComposerInstalledTestModulePaths ?? [];
370
+ if (isset ($ mockAggregateTestModulePaths )) {
371
+ $ mockMethods ['aggregateTestModulePaths ' ] = $ mockAggregateTestModulePaths ;
372
+ }
373
+ if (isset ($ mockNormalizeModuleNames )) {
374
+ $ mockMethods ['normalizeModuleNames ' ] = $ mockNormalizeModuleNames ;
375
+ }
376
+ if (isset ($ mockFlipAndFilterModulePathsArray )) {
377
+ $ mockMethods ['flipAndFilterModulePathsArray ' ] = $ mockFlipAndFilterModulePathsArray ;
378
+ }
316
379
317
380
$ mockResolver = AspectMock::double (
318
381
ModuleResolver::class,
0 commit comments