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