@@ -101,46 +101,28 @@ public function getRequiredChecks(): array
101101 */
102102 public function verify (Input $ input ): ResultInterface
103103 {
104+ $ scenario = $ this ->exercise ->defineTestScenario ();
105+
104106 $ this ->eventDispatcher ->dispatch (new CliExerciseRunnerEvent ('cli.verify.start ' , $ this ->exercise , $ input ));
105107 $ result = new CliResult (
106108 array_map (
107- function (array $ args ) use ($ input ) {
108- return $ this ->doVerify ($ args , $ input );
109+ function (Collection $ args ) use ($ input ) {
110+ return $ this ->doVerify ($ input , $ args );
109111 },
110- $ this -> preserveOldArgFormat ( $ this -> exercise -> getArgs () )
112+ $ scenario -> getExecutions ( )
111113 )
112114 );
113115 $ this ->eventDispatcher ->dispatch (new CliExerciseRunnerEvent ('cli.verify.finish ' , $ this ->exercise , $ input ));
114116 return $ result ;
115117 }
116118
117119 /**
118- * BC - getArgs only returned 1 set of args in v1 instead of multiple sets of args in v2
119- *
120- * @param array<int, array<string>>|array<int, string> $args
121- * @return array<int, array<string>>
122- */
123- private function preserveOldArgFormat (array $ args ): array
124- {
125- if (isset ($ args [0 ]) && !is_array ($ args [0 ])) {
126- $ args = [$ args ];
127- } elseif (count ($ args ) === 0 ) {
128- $ args = [[]];
129- }
130-
131- return $ args ;
132- }
133-
134- /**
135- * @param array<string> $args
136120 * @param Input $input
121+ * @param Collection<int, string> $args
137122 * @return CliResultInterface
138123 */
139- private function doVerify (array $ args , Input $ input ): CliResultInterface
124+ private function doVerify (Input $ input , Collection $ args ): CliResultInterface
140125 {
141- //arrays are not pass-by-ref
142- $ args = new ArrayObject ($ args );
143-
144126 try {
145127 /** @var CliExecuteEvent $event */
146128 $ event = $ this ->eventDispatcher ->dispatch (
@@ -213,12 +195,15 @@ private function doVerify(array $args, Input $input): CliResultInterface
213195 */
214196 public function run (Input $ input , OutputInterface $ output ): bool
215197 {
198+ $ scenario = $ this ->exercise ->defineTestScenario ();
199+
216200 $ this ->eventDispatcher ->dispatch (new CliExerciseRunnerEvent ('cli.run.start ' , $ this ->exercise , $ input ));
201+
217202 $ success = true ;
218- foreach ($ this -> preserveOldArgFormat ( $ this -> exercise -> getArgs () ) as $ i => $ args ) {
203+ foreach ($ scenario -> getExecutions ( ) as $ i => $ args ) {
219204 /** @var CliExecuteEvent $event */
220205 $ event = $ this ->eventDispatcher ->dispatch (
221- new CliExecuteEvent ('cli.run.student-execute.pre ' , $ this ->exercise , $ input , new ArrayObject ( $ args) )
206+ new CliExecuteEvent ('cli.run.student-execute.pre ' , $ this ->exercise , $ input , $ args )
222207 );
223208
224209 $ args = $ event ->getArgs ();
0 commit comments