@@ -101,46 +101,28 @@ public function getRequiredChecks(): array
101
101
*/
102
102
public function verify (Input $ input ): ResultInterface
103
103
{
104
+ $ scenario = $ this ->exercise ->defineTestScenario ();
105
+
104
106
$ this ->eventDispatcher ->dispatch (new CliExerciseRunnerEvent ('cli.verify.start ' , $ this ->exercise , $ input ));
105
107
$ result = new CliResult (
106
108
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 );
109
111
},
110
- $ this -> preserveOldArgFormat ( $ this -> exercise -> getArgs () )
112
+ $ scenario -> getExecutions ( )
111
113
)
112
114
);
113
115
$ this ->eventDispatcher ->dispatch (new CliExerciseRunnerEvent ('cli.verify.finish ' , $ this ->exercise , $ input ));
114
116
return $ result ;
115
117
}
116
118
117
119
/**
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
136
120
* @param Input $input
121
+ * @param Collection<int, string> $args
137
122
* @return CliResultInterface
138
123
*/
139
- private function doVerify (array $ args , Input $ input ): CliResultInterface
124
+ private function doVerify (Input $ input , Collection $ args ): CliResultInterface
140
125
{
141
- //arrays are not pass-by-ref
142
- $ args = new ArrayObject ($ args );
143
-
144
126
try {
145
127
/** @var CliExecuteEvent $event */
146
128
$ event = $ this ->eventDispatcher ->dispatch (
@@ -213,12 +195,15 @@ private function doVerify(array $args, Input $input): CliResultInterface
213
195
*/
214
196
public function run (Input $ input , OutputInterface $ output ): bool
215
197
{
198
+ $ scenario = $ this ->exercise ->defineTestScenario ();
199
+
216
200
$ this ->eventDispatcher ->dispatch (new CliExerciseRunnerEvent ('cli.run.start ' , $ this ->exercise , $ input ));
201
+
217
202
$ success = true ;
218
- foreach ($ this -> preserveOldArgFormat ( $ this -> exercise -> getArgs () ) as $ i => $ args ) {
203
+ foreach ($ scenario -> getExecutions ( ) as $ i => $ args ) {
219
204
/** @var CliExecuteEvent $event */
220
205
$ 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 )
222
207
);
223
208
224
209
$ args = $ event ->getArgs ();
0 commit comments