@@ -206,6 +206,8 @@ public function run(ExecutionContext $context, OutputInterface $output): bool
206
206
$ scenario = $ this ->exercise ->defineTestScenario ();
207
207
208
208
$ this ->environmentManager ->prepareStudent ($ context , $ scenario );
209
+ $ this ->environmentManager ->prepareReference ($ context , $ scenario );
210
+
209
211
210
212
$ this ->eventDispatcher ->dispatch (new CliExerciseRunnerEvent ('cli.run.start ' , $ context , $ scenario ));
211
213
@@ -222,6 +224,7 @@ public function run(ExecutionContext $context, OutputInterface $output): bool
222
224
$ context ->getStudentExecutionDirectory (),
223
225
$ context ->getEntryPoint (),
224
226
$ args ,
227
+ $ scenario ->getExposedPorts (),
225
228
);
226
229
227
230
$ process ->start ();
@@ -231,6 +234,7 @@ public function run(ExecutionContext $context, OutputInterface $output): bool
231
234
$ process ->wait (function ($ outputType , $ outputBuffer ) use ($ output ) {
232
235
$ output ->write ($ outputBuffer );
233
236
});
237
+
234
238
$ output ->emptyLine ();
235
239
236
240
if (!$ process ->isSuccessful ()) {
@@ -254,7 +258,7 @@ public function run(ExecutionContext $context, OutputInterface $output): bool
254
258
*/
255
259
private function executePhpFile (ExecutionContext $ context , CliScenario $ scenario , string $ workingDirectory , string $ fileName , Collection $ args , string $ type ): string
256
260
{
257
- $ process = $ this ->getPhpProcess ($ workingDirectory , $ fileName , $ args );
261
+ $ process = $ this ->getPhpProcess ($ workingDirectory , $ fileName , $ args, $ scenario -> getExposedPorts () );
258
262
259
263
$ process ->start ();
260
264
$ this ->eventDispatcher ->dispatch (
@@ -271,11 +275,12 @@ private function executePhpFile(ExecutionContext $context, CliScenario $scenario
271
275
272
276
/**
273
277
* @param Collection<int, string> $args
278
+ * @param list<int> $exposedPorts
274
279
*/
275
- private function getPhpProcess (string $ workingDirectory , string $ fileName , Collection $ args ): Process
280
+ private function getPhpProcess (string $ workingDirectory , string $ fileName , Collection $ args, array $ exposedPorts ): Process
276
281
{
277
282
return $ this ->processFactory ->create (
278
- new ProcessInput ('php ' , [$ fileName , ...$ args ->getArrayCopy ()], $ workingDirectory , []),
283
+ new ProcessInput ('php ' , [$ fileName , ...$ args ->getArrayCopy ()], $ workingDirectory , [], $ exposedPorts ),
279
284
);
280
285
}
281
286
}
0 commit comments