88namespace Magento \Setup ;
99
1010use Magento \Framework \App \ResourceConnection ;
11- use Magento \Framework \Setup \Mvc \MvcApplication ;
12- use Magento \Framework \Setup \Mvc \ServiceManagerFactory ;
1311
12+ use Magento \Framework \Shell ;
13+ use Magento \Framework \Shell \CommandRenderer ;
1414use Magento \TestFramework \Deploy \CliCommand ;
1515use Magento \TestFramework \Deploy \TestModuleManager ;
1616use Magento \TestFramework \Helper \Bootstrap ;
@@ -36,15 +36,20 @@ class SetupInstallMvcTest extends SetupTestCase
3636 */
3737 private $ resourceConnection ;
3838
39-
39+ /**
40+ * @var Shell
41+ */
42+ private $ shell ;
4043
4144 protected function setUp (): void
4245 {
4346 $ objectManager = Bootstrap::getObjectManager ();
4447 $ this ->moduleManager = $ objectManager ->get (TestModuleManager::class);
4548 $ this ->cliCommand = $ objectManager ->get (CliCommand::class);
4649 $ 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 ());
4853 }
4954
5055 /**
@@ -54,22 +59,22 @@ public function testCustomMvcClassesAvailableForSetupInstall()
5459 {
5560 // Verify that our custom MVC implementation is loaded and available
5661 $ this ->assertTrue (
57- class_exists (MvcApplication::class ),
62+ class_exists (' Magento\Framework\Setup\Mvc\ MvcApplication' ),
5863 'Custom MvcApplication must be available for setup:install command '
5964 );
6065
6166 $ this ->assertTrue (
62- class_exists (\ Magento \Framework \Setup \Mvc \MvcEvent::class ),
67+ class_exists (' Magento\Framework\Setup\Mvc\MvcEvent ' ),
6368 'Custom MvcEvent must be available for setup:install command '
6469 );
6570
6671 $ this ->assertTrue (
67- class_exists (\ Magento \Framework \Setup \Mvc \ModuleManager::class ),
72+ class_exists (' Magento\Framework\Setup\Mvc\ModuleManager ' ),
6873 'Custom ModuleManager must be available for setup:install command '
6974 );
7075
7176 $ this ->assertTrue (
72- class_exists (ServiceManagerFactory::class ),
77+ class_exists (' Magento\Framework\Setup\Mvc\ ServiceManagerFactory' ),
7378 'Custom ServiceManagerFactory must be available for setup:install command '
7479 );
7580
@@ -78,8 +83,9 @@ class_exists(ServiceManagerFactory::class),
7883 $ serviceManager ->setService ('EventManager ' , new \Laminas \EventManager \EventManager ());
7984 $ serviceManager ->setService ('config ' , ['setup ' => ['mode ' => 'install ' ]]);
8085
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 );
8389 }
8490
8591 /**
@@ -1022,15 +1028,7 @@ private function executeDiCompileCommand($params = [])
10221028 }
10231029
10241030 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 );
10341032 } catch (\Exception $ e ) {
10351033 // Check if this is the "modules are not enabled" error
10361034 $ errorMessage = $ e ->getMessage ();
0 commit comments