1717use PhpSchool \PhpWorkshop \ExerciseDispatcher ;
1818use PhpSchool \PhpWorkshop \ExerciseRunner \ExerciseRunnerInterface ;
1919use PhpSchool \PhpWorkshop \Factory \RunnerFactory ;
20+ use PhpSchool \PhpWorkshop \Input \Input ;
2021use PhpSchool \PhpWorkshop \Output \OutputInterface ;
2122use PhpSchool \PhpWorkshop \Result \Failure ;
2223use PhpSchool \PhpWorkshop \Result \Success ;
@@ -253,7 +254,7 @@ public function testVerifyThrowsExceptionIfCheckDoesNotSupportExerciseType()
253254 $ this ->expectException (CheckNotApplicableException::class);
254255 $ this ->expectExceptionMessage ($ msg );
255256
256- $ this ->exerciseDispatcher ->verify ($ this ->exercise , '' );
257+ $ this ->exerciseDispatcher ->verify ($ this ->exercise , new Input ( ' app ' ) );
257258 }
258259
259260 public function testVerifyThrowsExceptionIfExerciseDoesNotImplementCorrectInterface ()
@@ -274,12 +275,13 @@ public function testVerifyThrowsExceptionIfExerciseDoesNotImplementCorrectInterf
274275 $ this ->expectException (ExerciseNotConfiguredException::class);
275276 $ this ->expectExceptionMessage ('Exercise: "Some Exercise" should implement interface: "LolIDoNotExist" ' );
276277
277- $ this ->exerciseDispatcher ->verify ($ this ->exercise , '' );
278+ $ this ->exerciseDispatcher ->verify ($ this ->exercise , new Input ( ' app ' ) );
278279 }
279280
280281 public function testVerify ()
281282 {
282283 $ this ->createExercise ();
284+ $ input = new Input ('app ' , ['program ' => $ this ->file ]);
283285 $ this ->exercise
284286 ->expects ($ this ->once ())
285287 ->method ('configure ' )
@@ -305,19 +307,20 @@ public function testVerify()
305307 $ this ->runner
306308 ->expects ($ this ->once ())
307309 ->method ('verify ' )
308- ->with ($ this -> file )
310+ ->with ($ input )
309311 ->will ($ this ->returnValue ($ this ->createMock (SuccessInterface::class)));
310312
311313 $ this ->exerciseDispatcher ->requireCheck (get_class ($ this ->check ));
312314
313- $ result = $ this ->exerciseDispatcher ->verify ($ this ->exercise , $ this -> file );
315+ $ result = $ this ->exerciseDispatcher ->verify ($ this ->exercise , $ input );
314316 $ this ->assertInstanceOf (ResultAggregator::class, $ result );
315317 $ this ->assertTrue ($ result ->isSuccessful ());
316318 }
317319
318320 public function testVerifyOnlyRunsRequiredChecks ()
319321 {
320322 $ this ->createExercise ();
323+ $ input = new Input ('app ' , ['program ' => $ this ->file ]);
321324 $ this ->check
322325 ->expects ($ this ->exactly (2 ))
323326 ->method ('check ' )
@@ -346,22 +349,23 @@ public function testVerifyOnlyRunsRequiredChecks()
346349 $ this ->runner
347350 ->expects ($ this ->once ())
348351 ->method ('verify ' )
349- ->with ($ this -> file )
352+ ->with ($ input )
350353 ->will ($ this ->returnValue ($ this ->createMock (SuccessInterface::class)));
351354
352355 $ this ->checkRepository ->registerCheck ($ doNotRunMe );
353356
354357 $ this ->exerciseDispatcher ->requireCheck (get_class ($ this ->check ));
355358 $ this ->exerciseDispatcher ->requireCheck (get_class ($ this ->check ));
356359
357- $ result = $ this ->exerciseDispatcher ->verify ($ this ->exercise , $ this -> file );
360+ $ result = $ this ->exerciseDispatcher ->verify ($ this ->exercise , $ input );
358361 $ this ->assertInstanceOf (ResultAggregator::class, $ result );
359362 $ this ->assertTrue ($ result ->isSuccessful ());
360363 }
361364
362365 public function testWhenBeforeChecksFailTheyReturnImmediately ()
363366 {
364367 $ this ->createExercise ();
368+ $ input = new Input ('app ' , ['program ' => $ this ->file ]);
365369 $ this ->check
366370 ->expects ($ this ->once ())
367371 ->method ('check ' )
@@ -406,13 +410,14 @@ public function testWhenBeforeChecksFailTheyReturnImmediately()
406410 $ this ->exerciseDispatcher ->requireCheck (get_class ($ this ->check ));
407411 $ this ->exerciseDispatcher ->requireCheck (get_class ($ doNotRunMe ));
408412
409- $ result = $ this ->exerciseDispatcher ->verify ($ this ->exercise , $ this -> file );
413+ $ result = $ this ->exerciseDispatcher ->verify ($ this ->exercise , $ input );
410414 $ this ->assertInstanceOf (ResultAggregator::class, $ result );
411415 $ this ->assertFalse ($ result ->isSuccessful ());
412416 }
413417
414418 public function testAllEventsAreDispatched ()
415419 {
420+ $ input = new Input ('app ' , ['program ' => $ this ->file ]);
416421 $ this ->eventDispatcher
417422 ->expects ($ this ->exactly (5 ))
418423 ->method ('dispatch ' )
@@ -429,14 +434,15 @@ public function testAllEventsAreDispatched()
429434 $ this ->runner
430435 ->expects ($ this ->once ())
431436 ->method ('verify ' )
432- ->with ($ this -> file )
437+ ->with ($ input )
433438 ->will ($ this ->returnValue (new Success ('test ' )));
434439
435- $ this ->exerciseDispatcher ->verify ($ this ->exercise , $ this -> file );
440+ $ this ->exerciseDispatcher ->verify ($ this ->exercise , $ input );
436441 }
437442
438443 public function testVerifyPostExecuteIsStillDispatchedEvenIfRunnerThrowsException ()
439444 {
445+ $ input = new Input ('app ' , ['program ' => $ this ->file ]);
440446 $ this ->eventDispatcher
441447 ->expects ($ this ->exactly (3 ))
442448 ->method ('dispatch ' )
@@ -451,26 +457,27 @@ public function testVerifyPostExecuteIsStillDispatchedEvenIfRunnerThrowsExceptio
451457 $ this ->runner
452458 ->expects ($ this ->once ())
453459 ->method ('verify ' )
454- ->with ($ this -> file )
460+ ->with ($ input )
455461 ->will ($ this ->throwException (new RuntimeException ));
456462
457463 $ this ->expectException (RuntimeException::class);
458- $ this ->exerciseDispatcher ->verify ($ this ->exercise , $ this -> file );
464+ $ this ->exerciseDispatcher ->verify ($ this ->exercise , $ input );
459465 }
460466
461467 public function testRun ()
462468 {
469+ $ input = new Input ('app ' , ['program ' => $ this ->file ]);
463470 $ exercise = $ this ->createMock (ExerciseInterface::class);
464471 $ output = $ this ->createMock (OutputInterface::class);
465472
466473 $ this ->mockRunner ($ exercise );
467474 $ this ->runner
468475 ->expects ($ this ->once ())
469476 ->method ('run ' )
470- ->with ($ this -> file , $ output )
477+ ->with ($ input , $ output )
471478 ->will ($ this ->returnValue (true ));
472479
473- $ this ->assertTrue ($ this ->exerciseDispatcher ->run ($ exercise , $ this -> file , $ output ));
480+ $ this ->assertTrue ($ this ->exerciseDispatcher ->run ($ exercise , $ input , $ output ));
474481 }
475482
476483 public function tearDown ()
0 commit comments