1414use  PhpSchool \PhpWorkshop \ExerciseCheck \DatabaseExerciseCheck ;
1515use  PhpSchool \PhpWorkshop \ExerciseDispatcher ;
1616use  PhpSchool \PhpWorkshop \ExerciseRunner \CliRunner ;
17- use  PhpSchool \PhpWorkshop \Factory \ RunnerFactory ;
17+ use  PhpSchool \PhpWorkshop \ExerciseRunner \ RunnerManager ;
1818use  PhpSchool \PhpWorkshop \Input \Input ;
1919use  PhpSchool \PhpWorkshop \Output \OutputInterface ;
2020use  PhpSchool \PhpWorkshop \ResultAggregator ;
@@ -61,6 +61,7 @@ public function setUp()
6161
6262        $ this check  = new  DatabaseCheck ;
6363        $ this exercise  = $ this createMock (DatabaseExerciseInterface::class);
64+         $ this exercise ->expects ($ this any ())->method ('getType ' )->willReturn (ExerciseType::CLI ());
6465        $ this dbDir  = sprintf (
6566            '%s/PhpSchool_PhpWorkshop_Check_DatabaseCheck ' ,
6667            str_replace ('\\' , '/ ' , realpath (sys_get_temp_dir ()))
@@ -75,20 +76,25 @@ public function setUp()
7576     * @param EventDispatcher $eventDispatcher 
7677     * @return \PHPUnit_Framework_MockObject_MockObject 
7778     */ 
78-     private  function  getRunnerFactory (ExerciseInterface $ exerciseEventDispatcher $ eventDispatcher
79+     private  function  getRunnerManager (ExerciseInterface $ exerciseEventDispatcher $ eventDispatcher
7980    {
8081        $ runner$ this getMockBuilder (CliRunner::class)
8182            ->setConstructorArgs ([$ exercise$ eventDispatcher
82-             ->setMethods (['configure ' ])
83+             ->setMethods (['configure ' ,  ' getRequiredChecks ' 
8384            ->getMock ();
8485
85-         $ runnerFactory$ this createMock (RunnerFactory::class);
86-         $ runnerFactory
86+         $ runner
87+             ->expects ($ this any ())
88+             ->method ('getRequiredChecks ' )
89+             ->willReturn ([]);
90+ 
91+         $ runnerManager$ this createMock (RunnerManager::class);
92+         $ runnerManager
8793            ->expects ($ this once ())
88-             ->method ('create ' )
94+             ->method ('getRunner ' )
8995            ->willReturn ($ runner
9096
91-         return  $ runnerFactory 
97+         return  $ runnerManager 
9298    }
9399
94100    public  function  testIfDatabaseFolderExistsExceptionIsThrown ()
@@ -153,7 +159,7 @@ public function testIfPDOThrowsExceptionItCleansUp()
153159        $ resultsnew  ResultAggregator ;
154160        $ eventDispatchernew  EventDispatcher ($ results
155161        $ dispatchernew  ExerciseDispatcher (
156-             $ this getRunnerFactory ($ this exercise , $ eventDispatcher
162+             $ this getRunnerManager ($ this exercise , $ eventDispatcher
157163            $ results
158164            $ eventDispatcher
159165            $ this checkRepository 
@@ -194,7 +200,7 @@ public function testSuccessIsReturnedIfDatabaseVerificationPassed()
194200        $ resultsnew  ResultAggregator ;
195201        $ eventDispatchernew  EventDispatcher ($ results
196202        $ dispatchernew  ExerciseDispatcher (
197-             $ this getRunnerFactory ($ this exercise , $ eventDispatcher
203+             $ this getRunnerManager ($ this exercise , $ eventDispatcher
198204            $ results
199205            $ eventDispatcher
200206            $ this checkRepository 
@@ -225,7 +231,7 @@ public function testRunExercise()
225231        $ resultsnew  ResultAggregator ;
226232        $ eventDispatchernew  EventDispatcher ($ results
227233        $ dispatchernew  ExerciseDispatcher (
228-             $ this getRunnerFactory ($ this exercise , $ eventDispatcher
234+             $ this getRunnerManager ($ this exercise , $ eventDispatcher
229235            $ results
230236            $ eventDispatcher
231237            $ this checkRepository 
@@ -241,6 +247,8 @@ public function testRunExercise()
241247    public  function  testFailureIsReturnedIfDatabaseVerificationFails ()
242248    {
243249        $ solutionfromFile (realpath (__DIR__  . '/../res/database/solution.php ' ));
250+ 
251+ 
244252        $ this exercise 
245253            ->expects ($ this once ())
246254            ->method ('getSolution ' )
@@ -269,7 +277,7 @@ public function testFailureIsReturnedIfDatabaseVerificationFails()
269277        $ resultsnew  ResultAggregator ;
270278        $ eventDispatchernew  EventDispatcher ($ results
271279        $ dispatchernew  ExerciseDispatcher (
272-             $ this getRunnerFactory ($ this exercise , $ eventDispatcher
280+             $ this getRunnerManager ($ this exercise , $ eventDispatcher
273281            $ results
274282            $ eventDispatcher
275283            $ this checkRepository 
@@ -337,7 +345,7 @@ public function testAlteringDatabaseInSolutionDoesNotEffectDatabaseInUserSolutio
337345        $ resultsnew  ResultAggregator ;
338346        $ eventDispatchernew  EventDispatcher ($ results
339347        $ dispatchernew  ExerciseDispatcher (
340-             $ this getRunnerFactory ($ this exercise , $ eventDispatcher
348+             $ this getRunnerManager ($ this exercise , $ eventDispatcher
341349            $ results
342350            $ eventDispatcher
343351            $ this checkRepository 
0 commit comments