88use PhpSchool \PhpWorkshop \Event \CliExecuteEvent ;
99use PhpSchool \PhpWorkshop \Event \Event ;
1010use PhpSchool \PhpWorkshop \Event \EventDispatcher ;
11+ use PhpSchool \PhpWorkshop \Event \ExerciseRunnerEvent ;
1112use PhpSchool \PhpWorkshop \Exception \CodeExecutionException ;
1213use PhpSchool \PhpWorkshop \Exception \SolutionExecutionException ;
1314use PhpSchool \PhpWorkshop \Exercise \CliExercise ;
14- use PhpSchool \PhpWorkshop \ExerciseDispatcher ;
1515use PhpSchool \PhpWorkshop \Input \Input ;
1616use PhpSchool \PhpWorkshop \Output \OutputInterface ;
1717use PhpSchool \PhpWorkshop \Result \Failure ;
@@ -127,6 +127,18 @@ private function getPhpProcess($fileName, ArrayObject $args)
127127 * @return ResultInterface The result of the check.
128128 */
129129 public function verify (Input $ input )
130+ {
131+ $ this ->eventDispatcher ->dispatch (new ExerciseRunnerEvent ('cli.verify.start ' , $ this ->exercise , $ input ));
132+ $ result = $ this ->doVerify ($ input );
133+ $ this ->eventDispatcher ->dispatch (new ExerciseRunnerEvent ('cli.verify.finish ' , $ this ->exercise , $ input ));
134+ return $ result ;
135+ }
136+
137+ /**
138+ * @param Input $input
139+ * @return ResultInterface
140+ */
141+ private function doVerify (Input $ input )
130142 {
131143 //arrays are not pass-by-ref
132144 $ args = new ArrayObject ($ this ->exercise ->getArgs ());
@@ -175,6 +187,7 @@ public function verify(Input $input)
175187 */
176188 public function run (Input $ input , OutputInterface $ output )
177189 {
190+ $ this ->eventDispatcher ->dispatch (new ExerciseRunnerEvent ('cli.run.start ' , $ this ->exercise , $ input ));
178191 /** @var CliExecuteEvent $event */
179192 $ event = $ this ->eventDispatcher ->dispatch (
180193 new CliExecuteEvent ('cli.run.student-execute.pre ' , new ArrayObject ($ this ->exercise ->getArgs ()))
@@ -200,6 +213,7 @@ public function run(Input $input, OutputInterface $output)
200213 $ output ->writeLine ($ outputBuffer );
201214 });
202215
216+ $ this ->eventDispatcher ->dispatch (new ExerciseRunnerEvent ('cli.run.finish ' , $ this ->exercise , $ input ));
203217 return $ process ->isSuccessful ();
204218 }
205219}
0 commit comments