@@ -102,43 +102,26 @@ public function getRequiredChecks(): array
102102 */
103103 public function verify (ExecutionContext $ context ): ResultInterface
104104 {
105+ $ scenario = $ this ->exercise ->defineTestScenario ();
106+ 105107 $ this ->eventDispatcher ->dispatch (new CliExerciseRunnerEvent ('cli.verify.start ' , $ this ->exercise , $ context ->getInput ()));
106108 $ result = new CliResult (
107109 array_map (
108- function (array $ args ) use ($ context ) {
110+ function (Collection $ args ) use ($ context ) {
109111 return $ this ->doVerify ($ context , $ args );
110112 },
111- $ this -> preserveOldArgFormat ( $ this -> exercise -> getArgs () )
113+ $ scenario -> getExecutions ( )
112114 )
113115 );
114116 $ this ->eventDispatcher ->dispatch (new CliExerciseRunnerEvent ('cli.verify.finish ' , $ this ->exercise , $ context ->getInput ()));
115117 return $ result ;
116118 }
117119
118120 /**
119- * BC - getArgs only returned 1 set of args in v1 instead of multiple sets of args in v2
120- *
121- * @param array<int, array<string>>|array<int, string> $args
122- * @return array<int, array<string>>
123- */
124- private function preserveOldArgFormat (array $ args ): array
125- {
126- if (isset ($ args [0 ]) && !is_array ($ args [0 ])) {
127- $ args = [$ args ];
128- } elseif (count ($ args ) === 0 ) {
129- $ args = [[]];
130- }
131- 132- return $ args ;
133- }
134- 135- /**
136- * @param array<string> $args
121+ * @param Collection<int, string> $args
137122 */
138- private function doVerify (ExecutionContext $ context , array $ args ): CliResultInterface
123+ private function doVerify (ExecutionContext $ context , Collection $ args ): CliResultInterface
139124 {
140- //arrays are not pass-by-ref
141- $ args = new ArrayObject ($ args );
142125
143126 try {
144127 /** @var CliExecuteEvent $event */
@@ -214,12 +197,14 @@ private function doVerify(ExecutionContext $context, array $args): CliResultInte
214197 */
215198 public function run (ExecutionContext $ context , OutputInterface $ output ): bool
216199 {
200+ $ scenario = $ this ->exercise ->defineTestScenario ();
201+ 217202 $ this ->eventDispatcher ->dispatch (new CliExerciseRunnerEvent ('cli.run.start ' , $ this ->exercise , $ context ->getInput ()));
218203 $ success = true ;
219- foreach ($ this -> preserveOldArgFormat ( $ this -> exercise -> getArgs () ) as $ i => $ args ) {
204+ foreach ($ scenario -> getExecutions ( ) as $ i => $ args ) {
220205 /** @var CliExecuteEvent $event */
221206 $ event = $ this ->eventDispatcher ->dispatch (
222- new CliExecuteEvent ('cli.run.student-execute.pre ' , $ this ->exercise , $ context ->getInput (), new ArrayObject ( $ args) )
207+ new CliExecuteEvent ('cli.run.student-execute.pre ' , $ this ->exercise , $ context ->getInput (), $ args )
223208 );
224209
225210 $ args = $ event ->getArgs ();
0 commit comments