@@ -345,9 +345,92 @@ public function testGetComposerInstalledTestModulePathsForPathInvocation()
345
345
*
346
346
* @throws \Exception
347
347
*/
348
- public function testMergeFlipAndFilterModulePaths ()
348
+ public function testMergeFlipAndFilterModulePathsNoForceGenerate ()
349
349
{
350
350
$ this ->mockForceGenerate (false );
351
+ $ this ->setMockResolverClass (
352
+ false ,
353
+ null ,
354
+ null ,
355
+ null ,
356
+ null ,
357
+ null ,
358
+ null ,
359
+ null ,
360
+ null ,
361
+ [
362
+ 'composer ' . DIRECTORY_SEPARATOR . 'json ' . DIRECTORY_SEPARATOR . 'pathA ' =>
363
+ [
364
+ 'Magento_ModuleA '
365
+ ],
366
+ 'composer ' . DIRECTORY_SEPARATOR . 'json ' . DIRECTORY_SEPARATOR . 'pathB ' =>
367
+ [
368
+ 'Magento_ModuleB '
369
+ ],
370
+ ],
371
+ [
372
+ 'composer ' . DIRECTORY_SEPARATOR . 'install ' . DIRECTORY_SEPARATOR . 'pathD ' =>
373
+ [
374
+ 'Magento_ModuleD '
375
+ ],
376
+ 'composer ' . DIRECTORY_SEPARATOR . 'install ' . DIRECTORY_SEPARATOR . 'pathE ' =>
377
+ [
378
+ 'Magento_ModuleE '
379
+ ],
380
+ 'composer ' . DIRECTORY_SEPARATOR . 'install ' . DIRECTORY_SEPARATOR . 'pathC ' =>
381
+ [
382
+ 'Magento_ModuleC ' ,
383
+ 'Magento_ModuleB ' ,
384
+ ],
385
+ ],
386
+ [
387
+ 'some ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'example ' => ['Magento_Example ' ],
388
+ 'other ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'sample ' => ['Magento_Sample ' ],
389
+ 'some ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'path1 ' => ['Magento_Path1 ' ],
390
+ 'other ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'path2 ' => ['Magento_Path2 ' ],
391
+ 'some ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'path3 ' => ['Magento_Path3 ' ],
392
+ 'other ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'path4 ' => ['Magento_Path4 ' ],
393
+ ]
394
+ );
395
+
396
+ $ resolver = ModuleResolver::getInstance ();
397
+ $ this ->setMockResolverProperties (
398
+ $ resolver ,
399
+ null ,
400
+ [
401
+ 0 => 'Magento_Path1 ' ,
402
+ 1 => 'Magento_Path2 ' ,
403
+ 2 => 'Magento_Path4 ' ,
404
+ 3 => 'Magento_Example ' ,
405
+ 4 => 'Magento_ModuleB ' ,
406
+ 5 => 'Magento_ModuleD ' ,
407
+ 6 => 'Magento_Otherexample ' ,
408
+ 7 => 'Magento_ModuleC ' ,
409
+ ]
410
+ );
411
+ $ this ->assertEquals (
412
+ [
413
+ 'some ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'path1 ' ,
414
+ 'other ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'path2 ' ,
415
+ 'other ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'path4 ' ,
416
+ 'some ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'example ' ,
417
+ 'composer ' . DIRECTORY_SEPARATOR . 'json ' . DIRECTORY_SEPARATOR . 'pathB ' ,
418
+ 'composer ' . DIRECTORY_SEPARATOR . 'install ' . DIRECTORY_SEPARATOR . 'pathD ' ,
419
+ 'composer ' . DIRECTORY_SEPARATOR . 'install ' . DIRECTORY_SEPARATOR . 'pathC ' ,
420
+
421
+ ],
422
+ $ resolver ->getModulesPath ()
423
+ );
424
+ }
425
+
426
+ /**
427
+ * Validate mergeModulePaths() and flipAndFilterModulePathsArray()
428
+ *
429
+ * @throws \Exception
430
+ */
431
+ public function testMergeFlipAndFilterModulePathsForceGenerate ()
432
+ {
433
+ $ this ->mockForceGenerate (true );
351
434
$ this ->setMockResolverClass (
352
435
false ,
353
436
null ,
@@ -381,8 +464,8 @@ public function testMergeFlipAndFilterModulePaths()
381
464
],
382
465
],
383
466
[
384
- 'some ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'example ' => ['Magento_example ' ],
385
- 'other ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'sample ' => ['Magento_sample ' ],
467
+ 'some ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'example ' => ['Magento_Example ' ],
468
+ 'other ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'sample ' => ['Magento_Sample ' ],
386
469
]
387
470
);
388
471
@@ -394,16 +477,18 @@ public function testMergeFlipAndFilterModulePaths()
394
477
0 => 'Magento_ModuleB ' ,
395
478
1 => 'Magento_ModuleC ' ,
396
479
2 => 'Magento_ModuleD ' ,
397
- 3 => 'Magento_example ' ,
398
- 4 => 'Magento_otherexample '
480
+ 3 => 'Magento_Example ' ,
481
+ 4 => 'Magento_Otherexample '
399
482
]
400
483
);
401
484
$ this ->assertEquals (
402
485
[
403
486
'some ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'example ' ,
487
+ 'composer ' . DIRECTORY_SEPARATOR . 'json ' . DIRECTORY_SEPARATOR . 'pathA ' ,
404
488
'composer ' . DIRECTORY_SEPARATOR . 'json ' . DIRECTORY_SEPARATOR . 'pathB ' ,
405
489
'composer ' . DIRECTORY_SEPARATOR . 'install ' . DIRECTORY_SEPARATOR . 'pathA ' ,
406
- 'composer ' . DIRECTORY_SEPARATOR . 'install ' . DIRECTORY_SEPARATOR . 'pathB '
490
+ 'composer ' . DIRECTORY_SEPARATOR . 'install ' . DIRECTORY_SEPARATOR . 'pathB ' ,
491
+ 'other ' . DIRECTORY_SEPARATOR . 'path ' . DIRECTORY_SEPARATOR . 'sample '
407
492
],
408
493
$ resolver ->getModulesPath ()
409
494
);
@@ -508,6 +593,8 @@ public function testApplyCustomModuleMethods()
508
593
509
594
/**
510
595
* Validate blacklisted modules are removed
596
+ * Module paths are sorted according to module name in alphabetically ascending order
597
+ *
511
598
* @throws \Exception
512
599
*/
513
600
public function testGetModulePathsBlacklist ()
@@ -525,10 +612,10 @@ public function testGetModulePathsBlacklist()
525
612
[],
526
613
[],
527
614
[
528
- 'vendor ' => ['vendor ' ],
529
- 'appCode ' => ['appCode ' ],
530
- 'devTests ' => ['devTests ' ],
531
- 'thisPath ' => ['thisPath ' ]
615
+ 'thisPath/some/path4 ' => ['Some_Module4 ' ],
616
+ 'devTests/Magento/path3 ' => ['Magento_Module3 ' ],
617
+ 'appCode/Magento/path2 ' => ['Magento_Module2 ' ],
618
+ 'vendor/amazon/path1 ' => ['Amazon_Module1 ' ],
532
619
],
533
620
function ($ arg ) {
534
621
return $ arg ;
@@ -538,15 +625,15 @@ function ($arg) {
538
625
}
539
626
);
540
627
$ resolver = ModuleResolver::getInstance ();
541
- $ this ->setMockResolverProperties ($ resolver , null , null , ['devTests ' ]);
628
+ $ this ->setMockResolverProperties ($ resolver , null , null , ['Magento_Module3 ' ]);
542
629
$ this ->assertEquals (
543
- ['vendor ' , 'appCode ' , 'thisPath ' ],
630
+ ['vendor/amazon/path1 ' , 'appCode/Magento/path2 ' , 'thisPath/some/path4 ' ],
544
631
$ resolver ->getModulesPath ()
545
632
);
546
633
TestLoggingUtil::getInstance ()->validateMockLogStatement (
547
634
'info ' ,
548
635
'excluding module ' ,
549
- ['module ' => 'devTests ' ]
636
+ ['module ' => 'Magento_Module3 ' ]
550
637
);
551
638
}
552
639
@@ -654,6 +741,7 @@ public function testGetAdminTokenWithBadResponse()
654
741
* @param string[] $mockAggregateTestModulePaths
655
742
* @param string[] $mockNormalizeModuleNames
656
743
* @param string[] $mockFlipAndFilterModulePathsArray
744
+ * @param string[] $mockFlipAndSortModulePathsArray
657
745
* @throws \Exception
658
746
* @return Verifier ModuleResolver double
659
747
*/
@@ -671,7 +759,8 @@ private function setMockResolverClass(
671
759
$ mockGetComposerInstalledTestModulePaths = null ,
672
760
$ mockAggregateTestModulePaths = null ,
673
761
$ mockNormalizeModuleNames = null ,
674
- $ mockFlipAndFilterModulePathsArray = null
762
+ $ mockFlipAndFilterModulePathsArray = null ,
763
+ $ mockFlipAndSortModulePathsArray = null
675
764
) {
676
765
$ property = new \ReflectionProperty (ModuleResolver::class, 'instance ' );
677
766
$ property ->setAccessible (true );
@@ -721,7 +810,9 @@ private function setMockResolverClass(
721
810
if (isset ($ mockFlipAndFilterModulePathsArray )) {
722
811
$ mockMethods ['flipAndFilterModulePathsArray ' ] = $ mockFlipAndFilterModulePathsArray ;
723
812
}
724
-
813
+ if (isset ($ mockFlipAndSortModulePathsArray )) {
814
+ $ mockMethods ['flipAndSortModulePathsArray ' ] = $ mockFlipAndSortModulePathsArray ;
815
+ }
725
816
$ mockResolver = AspectMock::double (
726
817
ModuleResolver::class,
727
818
$ mockMethods
0 commit comments