@@ -206,6 +206,8 @@ public function run(ExecutionContext $context, OutputInterface $output): bool
206206 $ scenario = $ this ->exercise ->defineTestScenario ();
207207
208208 $ this ->environmentManager ->prepareStudent ($ context , $ scenario );
209+ $ this ->environmentManager ->prepareReference ($ context , $ scenario );
210+
209211
210212 $ this ->eventDispatcher ->dispatch (new CliExerciseRunnerEvent ('cli.run.start ' , $ context , $ scenario ));
211213
@@ -222,6 +224,7 @@ public function run(ExecutionContext $context, OutputInterface $output): bool
222224 $ context ->getStudentExecutionDirectory (),
223225 $ context ->getEntryPoint (),
224226 $ args ,
227+ $ scenario ->getExposedPorts (),
225228 );
226229
227230 $ process ->start ();
@@ -231,6 +234,7 @@ public function run(ExecutionContext $context, OutputInterface $output): bool
231234 $ process ->wait (function ($ outputType , $ outputBuffer ) use ($ output ) {
232235 $ output ->write ($ outputBuffer );
233236 });
237+
234238 $ output ->emptyLine ();
235239
236240 if (!$ process ->isSuccessful ()) {
@@ -254,7 +258,7 @@ public function run(ExecutionContext $context, OutputInterface $output): bool
254258 */
255259 private function executePhpFile (ExecutionContext $ context , CliScenario $ scenario , string $ workingDirectory , string $ fileName , Collection $ args , string $ type ): string
256260 {
257- $ process = $ this ->getPhpProcess ($ workingDirectory , $ fileName , $ args );
261+ $ process = $ this ->getPhpProcess ($ workingDirectory , $ fileName , $ args, $ scenario -> getExposedPorts () );
258262
259263 $ process ->start ();
260264 $ this ->eventDispatcher ->dispatch (
@@ -271,11 +275,12 @@ private function executePhpFile(ExecutionContext $context, CliScenario $scenario
271275
272276 /**
273277 * @param Collection<int, string> $args
278+ * @param list<int> $exposedPorts
274279 */
275- private function getPhpProcess (string $ workingDirectory , string $ fileName , Collection $ args ): Process
280+ private function getPhpProcess (string $ workingDirectory , string $ fileName , Collection $ args, array $ exposedPorts ): Process
276281 {
277282 return $ this ->processFactory ->create (
278- new ProcessInput ('php ' , [$ fileName , ...$ args ->getArrayCopy ()], $ workingDirectory , []),
283+ new ProcessInput ('php ' , [$ fileName , ...$ args ->getArrayCopy ()], $ workingDirectory , [], $ exposedPorts ),
279284 );
280285 }
281286}
0 commit comments