@@ -56,22 +56,29 @@ public function testGetModulePathsAlreadySet()
5656 */
5757 public function testGetModulePathsAggregate ()
5858 {
59+
5960 $ this ->mockForceGenerate (false );
6061 $ this ->setMockResolverClass (
6162 false ,
6263 null ,
6364 null ,
6465 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+ ]
6675 );
6776 $ resolver = ModuleResolver::getInstance ();
68- $ this ->setMockResolverProperties ($ resolver , null , [0 => " Magento_example " ]);
77+ $ this ->setMockResolverProperties ($ resolver , null , [0 => ' Magento_example ' , 1 => ' Magento_sample ' ]);
6978 $ this ->assertEquals (
7079 [
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 '
7582 ],
7683 $ resolver ->getModulesPath ()
7784 );
@@ -91,20 +98,28 @@ public function testGetModulePathsLocations()
9198 $ this ->mockForceGenerate (false );
9299 $ mockResolver = $ this ->setMockResolverClass (
93100 true ,
94- [0 => " example " ],
101+ [],
95102 null ,
96103 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+ }
98118 );
99119 $ resolver = ModuleResolver::getInstance ();
100120 $ this ->setMockResolverProperties ($ resolver , null , null );
101121 $ 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+ [],
108123 $ resolver ->getModulesPath ()
109124 );
110125
@@ -114,8 +129,6 @@ public function testGetModulePathsLocations()
114129 // Define the Module paths from default TESTS_MODULE_PATH
115130 $ modulePath = defined ('TESTS_MODULE_PATH ' ) ? TESTS_MODULE_PATH : TESTS_BP ;
116131
117-
118-
119132 $ mockResolver ->verifyInvoked ('globRelevantPaths ' , [$ modulePath , '' ]);
120133 $ mockResolver ->verifyInvoked (
121134 'globRelevantPaths ' ,
@@ -150,14 +163,21 @@ public function testGetModulePathsLocations()
150163 */
151164 public function testGetCustomModulePath ()
152165 {
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+ );
154174 $ resolver = ModuleResolver::getInstance ();
155175 $ this ->setMockResolverProperties ($ resolver , null , null , null );
156176 $ this ->assertEquals (['otherPath ' ], $ resolver ->getModulesPath ());
157177 TestLoggingUtil::getInstance ()->validateMockLogStatement (
158178 'info ' ,
159179 'including custom module ' ,
160- ['module ' => 'otherPath ' ]
180+ ['Magento_Module ' => 'otherPath ' ]
161181 );
162182 }
163183
@@ -172,25 +192,36 @@ public function testGetModulePathsBlacklist()
172192 null ,
173193 null ,
174194 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 ;
182213 }
183214 );
184215 $ resolver = ModuleResolver::getInstance ();
185- $ this ->setMockResolverProperties ($ resolver , null , null , ["somePath " ]);
216+ $ this ->setMockResolverProperties ($ resolver , null , null , ["devTests " => " devTests " ]);
186217 $ this ->assertEquals (
187- ["lastPath " , "lastPath " ],
218+ ["vendor " , "appCode " , " thisPath " ],
188219 $ resolver ->getModulesPath ()
189220 );
190221 TestLoggingUtil::getInstance ()->validateMockLogStatement (
191222 'info ' ,
192223 'excluding module ' ,
193- ['module ' => 'somePath ' ]
224+ ['module ' => 'devTests ' ]
194225 );
195226 }
196227
@@ -278,6 +309,14 @@ public function testGetAdminTokenWithBadResponse()
278309 * @param string[] $mockGlob
279310 * @param string[] $mockRelativePaths
280311 * @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
281320 * @throws \Exception
282321 * @return Verifier ModuleResolver double
283322 */
@@ -287,7 +326,15 @@ private function setMockResolverClass(
287326 $ mockCustomMethods = null ,
288327 $ mockGlob = null ,
289328 $ 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
291338 ) {
292339 $ property = new \ReflectionProperty (ModuleResolver::class, 'instance ' );
293340 $ property ->setAccessible (true );
@@ -312,7 +359,23 @@ private function setMockResolverClass(
312359 if (isset ($ mockCustomModules )) {
313360 $ mockMethods ['getCustomModulePaths ' ] = $ mockCustomModules ;
314361 }
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+ }
316379
317380 $ mockResolver = AspectMock::double (
318381 ModuleResolver::class,
0 commit comments