8
8
namespace Magento \Setup ;
9
9
10
10
use Magento \Framework \App \ResourceConnection ;
11
- use Magento \Framework \Setup \Mvc \MvcApplication ;
12
- use Magento \Framework \Setup \Mvc \ServiceManagerFactory ;
13
11
12
+ use Magento \Framework \Shell ;
13
+ use Magento \Framework \Shell \CommandRenderer ;
14
14
use Magento \TestFramework \Deploy \CliCommand ;
15
15
use Magento \TestFramework \Deploy \TestModuleManager ;
16
16
use Magento \TestFramework \Helper \Bootstrap ;
@@ -36,15 +36,20 @@ class SetupInstallMvcTest extends SetupTestCase
36
36
*/
37
37
private $ resourceConnection ;
38
38
39
-
39
+ /**
40
+ * @var Shell
41
+ */
42
+ private $ shell ;
40
43
41
44
protected function setUp (): void
42
45
{
43
46
$ objectManager = Bootstrap::getObjectManager ();
44
47
$ this ->moduleManager = $ objectManager ->get (TestModuleManager::class);
45
48
$ this ->cliCommand = $ objectManager ->get (CliCommand::class);
46
49
$ this ->resourceConnection = $ objectManager ->get (ResourceConnection::class);
47
-
50
+
51
+ // Create Shell instance manually to avoid DI circular dependency issues
52
+ $ this ->shell = new Shell (new CommandRenderer ());
48
53
}
49
54
50
55
/**
@@ -54,22 +59,22 @@ public function testCustomMvcClassesAvailableForSetupInstall()
54
59
{
55
60
// Verify that our custom MVC implementation is loaded and available
56
61
$ this ->assertTrue (
57
- class_exists (MvcApplication::class ),
62
+ class_exists (' Magento\Framework\Setup\Mvc\ MvcApplication' ),
58
63
'Custom MvcApplication must be available for setup:install command '
59
64
);
60
65
61
66
$ this ->assertTrue (
62
- class_exists (\ Magento \Framework \Setup \Mvc \MvcEvent::class ),
67
+ class_exists (' Magento\Framework\Setup\Mvc\MvcEvent ' ),
63
68
'Custom MvcEvent must be available for setup:install command '
64
69
);
65
70
66
71
$ this ->assertTrue (
67
- class_exists (\ Magento \Framework \Setup \Mvc \ModuleManager::class ),
72
+ class_exists (' Magento\Framework\Setup\Mvc\ModuleManager ' ),
68
73
'Custom ModuleManager must be available for setup:install command '
69
74
);
70
75
71
76
$ this ->assertTrue (
72
- class_exists (ServiceManagerFactory::class ),
77
+ class_exists (' Magento\Framework\Setup\Mvc\ ServiceManagerFactory' ),
73
78
'Custom ServiceManagerFactory must be available for setup:install command '
74
79
);
75
80
@@ -78,8 +83,9 @@ class_exists(ServiceManagerFactory::class),
78
83
$ serviceManager ->setService ('EventManager ' , new \Laminas \EventManager \EventManager ());
79
84
$ serviceManager ->setService ('config ' , ['setup ' => ['mode ' => 'install ' ]]);
80
85
81
- $ mvcApplication = new MvcApplication ($ serviceManager );
82
- $ this ->assertInstanceOf (MvcApplication::class, $ mvcApplication );
86
+ $ mvcApplicationClass = 'Magento\Framework\Setup\Mvc\MvcApplication ' ;
87
+ $ mvcApplication = new $ mvcApplicationClass ($ serviceManager );
88
+ $ this ->assertInstanceOf ($ mvcApplicationClass , $ mvcApplication );
83
89
}
84
90
85
91
/**
@@ -1022,15 +1028,7 @@ private function executeDiCompileCommand($params = [])
1022
1028
}
1023
1029
1024
1030
try {
1025
- $ output = [];
1026
- $ returnCode = 0 ;
1027
- exec ($ diCompileCommand . ' 2>&1 ' , $ output , $ returnCode );
1028
-
1029
- if ($ returnCode !== 0 ) {
1030
- throw new \Exception (implode ("\n" , $ output ));
1031
- }
1032
-
1033
- return implode ("\n" , $ output );
1031
+ return $ this ->shell ->execute ($ diCompileCommand );
1034
1032
} catch (\Exception $ e ) {
1035
1033
// Check if this is the "modules are not enabled" error
1036
1034
$ errorMessage = $ e ->getMessage ();
0 commit comments